Skip to content

Commit

Permalink
Merge pull request #426 from carlosmn/checkout-init-options
Browse files Browse the repository at this point in the history
Properly initialize the clone options
  • Loading branch information
carlosmn committed Sep 13, 2014
2 parents 51da3b7 + 7d34d2b commit 5bc6a98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pygit2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def init_repository(path, bare=False,

# Options
options = ffi.new('git_repository_init_options *')
options.version = 1
C.git_repository_init_init_options(options, C.GIT_REPOSITORY_INIT_OPTIONS_VERSION)
options.flags = flags
options.mode = mode
options.workdir_path = to_bytes(workdir_path)
Expand Down Expand Up @@ -151,6 +151,9 @@ def clone_repository(
d['callback'] = credentials
d_handle = ffi.new_handle(d)

# Perform the initialization with the version we compiled
C.git_clone_init_options(opts, C.GIT_CLONE_OPTIONS_VERSION)

# We need to keep the ref alive ourselves
checkout_branch_ref = None
if branch:
Expand All @@ -160,11 +163,8 @@ def clone_repository(
remote_name_ref = ffi.new('char []', to_bytes(remote_name))
opts.remote_name = remote_name_ref

opts.version = 1
opts.ignore_cert_errors = ignore_cert_errors
opts.bare = bare
opts.remote_callbacks.version = 1
opts.checkout_opts.version = 1
if credentials:
opts.remote_callbacks.credentials = _credentials_cb
opts.remote_callbacks.payload = d_handle
Expand Down
6 changes: 6 additions & 0 deletions pygit2/decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ typedef struct git_clone_options {
git_signature *signature;
} git_clone_options;

#define GIT_CLONE_OPTIONS_VERSION ...
int git_clone_init_options(git_clone_options *opts, unsigned int version);

int git_clone(git_repository **out,
const char *url,
const char *local_path,
Expand Down Expand Up @@ -459,6 +462,9 @@ typedef struct {
const char *origin_url;
} git_repository_init_options;

#define GIT_REPOSITORY_INIT_OPTIONS_VERSION ...
int git_repository_init_init_options(git_repository_init_options *opts, int version);

int git_repository_init(
git_repository **out,
const char *path,
Expand Down

0 comments on commit 5bc6a98

Please sign in to comment.