Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly initialize the clone options #426

Merged
merged 2 commits into from
Sep 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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