Expose the pygit2.GIT_REPOSITORY_INIT_* constants

Fixes #483
This commit is contained in:
J. David Ibáñez 2015-02-01 10:51:10 +01:00
parent 961d007b02
commit 7f21f6eb63
3 changed files with 28 additions and 8 deletions

@ -28,6 +28,9 @@ Changelog
0.22.1 (not yet released)
-------------------------
- Expose the pygit2.GIT_REPOSITORY_INIT_* constants
`#483 <https://github.com/libgit2/pygit2/issues/483>`_
- Make pygit work in a frozen environment
`#453 <https://github.com/libgit2/pygit2/pull/453>`_

@ -45,8 +45,28 @@ from .utils import to_bytes, to_str
from ._utils import __version__
# Features
features = C.git_libgit2_features()
GIT_FEATURE_THREADS = C.GIT_FEATURE_THREADS
GIT_FEATURE_HTTPS = C.GIT_FEATURE_HTTPS
GIT_FEATURE_SSH = C.GIT_FEATURE_SSH
# GIT_REPOSITORY_INIT_*
GIT_REPOSITORY_INIT_OPTIONS_VERSION = C.GIT_REPOSITORY_INIT_OPTIONS_VERSION
GIT_REPOSITORY_INIT_BARE = C.GIT_REPOSITORY_INIT_BARE
GIT_REPOSITORY_INIT_NO_REINIT = C.GIT_REPOSITORY_INIT_NO_REINIT
GIT_REPOSITORY_INIT_NO_DOTGIT_DIR = C.GIT_REPOSITORY_INIT_NO_DOTGIT_DIR
GIT_REPOSITORY_INIT_MKDIR = C.GIT_REPOSITORY_INIT_MKDIR
GIT_REPOSITORY_INIT_MKPATH = C.GIT_REPOSITORY_INIT_MKPATH
GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE = C.GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE
GIT_REPOSITORY_INIT_RELATIVE_GITLINK = C.GIT_REPOSITORY_INIT_RELATIVE_GITLINK
GIT_REPOSITORY_INIT_SHARED_UMASK = C.GIT_REPOSITORY_INIT_SHARED_UMASK
GIT_REPOSITORY_INIT_SHARED_GROUP = C.GIT_REPOSITORY_INIT_SHARED_GROUP
GIT_REPOSITORY_INIT_SHARED_ALL = C.GIT_REPOSITORY_INIT_SHARED_ALL
def init_repository(path, bare=False,
flags=C.GIT_REPOSITORY_INIT_MKPATH,
flags=GIT_REPOSITORY_INIT_MKPATH,
mode=0,
workdir_path=None,
description=None,
@ -79,11 +99,12 @@ def init_repository(path, bare=False,
"""
# Pre-process input parameters
if bare:
flags |= C.GIT_REPOSITORY_INIT_BARE
flags |= GIT_REPOSITORY_INIT_BARE
# Options
options = ffi.new('git_repository_init_options *')
C.git_repository_init_init_options(options, C.GIT_REPOSITORY_INIT_OPTIONS_VERSION)
C.git_repository_init_init_options(options,
GIT_REPOSITORY_INIT_OPTIONS_VERSION)
options.flags = flags
options.mode = mode
@ -267,8 +288,3 @@ def clone_repository(
return Repository._from_c(crepo[0], owned=True)
settings = Settings()
features = C.git_libgit2_features()
GIT_FEATURE_THREADS = C.GIT_FEATURE_THREADS
GIT_FEATURE_HTTPS = C.GIT_FEATURE_HTTPS
GIT_FEATURE_SSH = C.GIT_FEATURE_SSH

@ -498,6 +498,7 @@ typedef enum {
GIT_REPOSITORY_INIT_MKDIR,
GIT_REPOSITORY_INIT_MKPATH,
GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE,
GIT_REPOSITORY_INIT_RELATIVE_GITLINK,
...
} git_repository_init_flag_t;