From d58a64e9a5d32b511447943f20a84340b520872f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 30 Jun 2014 20:55:32 +0200 Subject: 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. --- src/clone.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') 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))) { -- cgit v1.2.1