Skip to content

Commit 5bc6a98

Browse files
committed
Merge pull request #426 from carlosmn/checkout-init-options
Properly initialize the clone options
2 parents 51da3b7 + 7d34d2b commit 5bc6a98

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

pygit2/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def init_repository(path, bare=False,
8282

8383
# Options
8484
options = ffi.new('git_repository_init_options *')
85-
options.version = 1
85+
C.git_repository_init_init_options(options, C.GIT_REPOSITORY_INIT_OPTIONS_VERSION)
8686
options.flags = flags
8787
options.mode = mode
8888
options.workdir_path = to_bytes(workdir_path)
@@ -151,6 +151,9 @@ def clone_repository(
151151
d['callback'] = credentials
152152
d_handle = ffi.new_handle(d)
153153

154+
# Perform the initialization with the version we compiled
155+
C.git_clone_init_options(opts, C.GIT_CLONE_OPTIONS_VERSION)
156+
154157
# We need to keep the ref alive ourselves
155158
checkout_branch_ref = None
156159
if branch:
@@ -160,11 +163,8 @@ def clone_repository(
160163
remote_name_ref = ffi.new('char []', to_bytes(remote_name))
161164
opts.remote_name = remote_name_ref
162165

163-
opts.version = 1
164166
opts.ignore_cert_errors = ignore_cert_errors
165167
opts.bare = bare
166-
opts.remote_callbacks.version = 1
167-
opts.checkout_opts.version = 1
168168
if credentials:
169169
opts.remote_callbacks.credentials = _credentials_cb
170170
opts.remote_callbacks.payload = d_handle

pygit2/decl.h

+6
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ typedef struct git_clone_options {
353353
git_signature *signature;
354354
} git_clone_options;
355355

356+
#define GIT_CLONE_OPTIONS_VERSION ...
357+
int git_clone_init_options(git_clone_options *opts, unsigned int version);
358+
356359
int git_clone(git_repository **out,
357360
const char *url,
358361
const char *local_path,
@@ -459,6 +462,9 @@ typedef struct {
459462
const char *origin_url;
460463
} git_repository_init_options;
461464

465+
#define GIT_REPOSITORY_INIT_OPTIONS_VERSION ...
466+
int git_repository_init_init_options(git_repository_init_options *opts, int version);
467+
462468
int git_repository_init(
463469
git_repository **out,
464470
const char *path,

0 commit comments

Comments
 (0)