diff options
Diffstat (limited to 'src/clone.c')
| -rw-r--r-- | src/clone.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/src/clone.c b/src/clone.c index 85e69ad97..ab8b9bcbb 100644 --- a/src/clone.c +++ b/src/clone.c @@ -248,22 +248,20 @@ cleanup: -static int setup_remotes_and_fetch(git_repository *repo, - const char *origin_url, - git_indexer_stats *fetch_stats) +static int setup_remotes_and_fetch( + git_repository *repo, + const char *origin_url, + git_transfer_progress_callback progress_cb, + void *progress_payload) { int retcode = GIT_ERROR; git_remote *origin = NULL; - git_off_t bytes = 0; - git_indexer_stats dummy_stats; - - if (!fetch_stats) fetch_stats = &dummy_stats; /* Create the "origin" remote */ if (!git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, origin_url)) { /* Connect and download everything */ if (!git_remote_connect(origin, GIT_DIR_FETCH)) { - if (!git_remote_download(origin, &bytes, fetch_stats)) { + if (!git_remote_download(origin, progress_cb, progress_payload)) { /* Create "origin/foo" branches for all remote branches */ if (!git_remote_update_tips(origin)) { /* Point HEAD to the same ref as the remote's head */ @@ -311,23 +309,21 @@ static int clone_internal( git_repository **out, const char *origin_url, const char *path, - git_indexer_stats *fetch_stats, - git_indexer_stats *checkout_stats, + git_transfer_progress_callback fetch_progress_cb, + void *fetch_progress_payload, git_checkout_opts *checkout_opts, bool is_bare) { int retcode = GIT_ERROR; git_repository *repo = NULL; - git_indexer_stats dummy_stats; - - if (!fetch_stats) fetch_stats = &dummy_stats; if (!path_is_okay(path)) { return GIT_ERROR; } if (!(retcode = git_repository_init(&repo, path, is_bare))) { - if ((retcode = setup_remotes_and_fetch(repo, origin_url, fetch_stats)) < 0) { + if ((retcode = setup_remotes_and_fetch(repo, origin_url, + fetch_progress_cb, fetch_progress_payload)) < 0) { /* Failed to fetch; clean up */ git_repository_free(repo); git_futils_rmdir_r(path, NULL, GIT_DIRREMOVAL_FILES_AND_DIRS); @@ -338,15 +334,17 @@ static int clone_internal( } if (!retcode && should_checkout(repo, is_bare, checkout_opts)) - retcode = git_checkout_head(*out, checkout_opts, checkout_stats); + retcode = git_checkout_head(*out, checkout_opts); return retcode; } -int git_clone_bare(git_repository **out, - const char *origin_url, - const char *dest_path, - git_indexer_stats *fetch_stats) +int git_clone_bare( + git_repository **out, + const char *origin_url, + const char *dest_path, + git_transfer_progress_callback fetch_progress_cb, + void *fetch_progress_payload) { assert(out && origin_url && dest_path); @@ -354,19 +352,20 @@ int git_clone_bare(git_repository **out, out, origin_url, dest_path, - fetch_stats, - NULL, + fetch_progress_cb, + fetch_progress_payload, NULL, 1); } -int git_clone(git_repository **out, - const char *origin_url, - const char *workdir_path, - git_indexer_stats *fetch_stats, - git_indexer_stats *checkout_stats, - git_checkout_opts *checkout_opts) +int git_clone( + git_repository **out, + const char *origin_url, + const char *workdir_path, + git_transfer_progress_callback fetch_progress_cb, + void *fetch_progress_payload, + git_checkout_opts *checkout_opts) { assert(out && origin_url && workdir_path); @@ -374,8 +373,8 @@ int git_clone(git_repository **out, out, origin_url, workdir_path, - fetch_stats, - checkout_stats, + fetch_progress_cb, + fetch_progress_payload, checkout_opts, 0); } |
