diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-06-30 20:55:32 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-07-02 07:05:00 +0200 |
commit | d58a64e9a5d32b511447943f20a84340b520872f (patch) | |
tree | 5b1dc2b7a8a3c24b7c62de61bb249084afbf7521 /src | |
parent | dcdb8500e3bd719010a1a65fffc391eef23dd4b4 (diff) | |
download | libgit2-d58a64e9a5d32b511447943f20a84340b520872f.tar.gz |
clone: add a callback for repository creation
Analogously to the remote creation callback, provide a way for the user
of git_clone() to create the repository with whichever options they
desire via callback.
Diffstat (limited to 'src')
-rw-r--r-- | src/clone.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/clone.c b/src/clone.c index a4ed1a29c..8894f97ea 100644 --- a/src/clone.c +++ b/src/clone.c @@ -229,6 +229,13 @@ cleanup: return retcode; } +static int default_repository_create(git_repository **out, const char *path, int bare, void *payload) +{ + GIT_UNUSED(payload); + + return git_repository_init(out, path, bare); +} + static int default_remote_create( git_remote **out, git_repository *repo, @@ -396,6 +403,7 @@ int git_clone( git_remote *origin; git_clone_options options = GIT_CLONE_OPTIONS_INIT; uint32_t rmdir_flags = GIT_RMDIR_REMOVE_FILES; + git_repository_create_cb repository_cb; assert(out && url && local_path); @@ -415,7 +423,12 @@ int git_clone( if (git_path_exists(local_path)) rmdir_flags |= GIT_RMDIR_SKIP_ROOT; - if ((error = git_repository_init(&repo, local_path, options.bare)) < 0) + if (options.repository_cb) + repository_cb = options.repository_cb; + else + repository_cb = default_repository_create; + + if ((error = repository_cb(&repo, local_path, options.bare, options.repository_cb_payload)) < 0) return error; if (!(error = create_and_configure_origin(&origin, repo, url, &options))) { |