Skip to content

Commit c5f8d20

Browse files
committed
Properly initialize the clone options
libgit2 provides an initialization function to set sane defaults. Use that instead of setting the version by hand, as that's not the only thing it does. Using C.git_clone_init_options() sets the checkout strategy to SAFE, which will checkout the files after the clone, instead of the implicit NONE which we're setting by hand. This fixes #425,
1 parent 51da3b7 commit c5f8d20

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

pygit2/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def clone_repository(
160160
remote_name_ref = ffi.new('char []', to_bytes(remote_name))
161161
opts.remote_name = remote_name_ref
162162

163-
opts.version = 1
163+
C.git_clone_init_options(opts, 1)
164164
opts.ignore_cert_errors = ignore_cert_errors
165165
opts.bare = bare
166166
opts.remote_callbacks.version = 1

pygit2/decl.h

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

356+
int git_clone_init_options(git_clone_options *opts, unsigned int version);
357+
356358
int git_clone(git_repository **out,
357359
const char *url,
358360
const char *local_path,

0 commit comments

Comments
 (0)