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,
This commit is contained in:
Carlos Martín Nieto
2014-09-13 17:30:32 +02:00
parent 51da3b767d
commit 63377aad78
2 changed files with 6 additions and 3 deletions

View File

@@ -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:
@@ -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

View File

@@ -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,