summaryrefslogtreecommitdiff
path: root/src/clone.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-04-21 22:10:36 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-05-13 09:46:35 +0200
commit8f0104ecc54db00a075310ab744a19eb60e3d740 (patch)
tree775b3237a853c556a4d44840fc6c562e7b114415 /src/clone.c
parent05259114427234831cf4915cbe40a5bb8ea021b0 (diff)
downloadlibgit2-8f0104ecc54db00a075310ab744a19eb60e3d740.tar.gz
Remove the callbacks struct from the remote
Having the setting be different from calling its actions was not a great idea and made for the sake of the wrong convenience. Instead of that, accept either fetch options, push options or the callbacks when dealing with the remote. The fetch options are currently only the callbacks, but more options will be moved from setters and getters on the remote to the options. This does mean passing the same struct along the different functions but the typical use-case will only call git_remote_fetch() or git_remote_push() and so won't notice much difference.
Diffstat (limited to 'src/clone.c')
-rw-r--r--src/clone.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/clone.c b/src/clone.c
index 7e5d3302e..53cdae673 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -24,7 +24,7 @@
#include "repository.h"
#include "odb.h"
-static int clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link);
+static int clone_local_into(git_repository *repo, git_remote *remote, const git_fetch_options *fetch_opts, const git_checkout_options *co_opts, const char *branch, int link);
static int create_branch(
git_reference **branch,
@@ -242,13 +242,9 @@ static int default_remote_create(
const char *url,
void *payload)
{
- int error;
- git_remote_callbacks *callbacks = payload;
-
- if ((error = git_remote_create(out, repo, name, url)) < 0)
- return error;
+ GIT_UNUSED(payload);
- return git_remote_set_callbacks(*out, callbacks);
+ return git_remote_create(out, repo, name, url);
}
/*
@@ -277,7 +273,7 @@ static int create_and_configure_origin(
if (!remote_create) {
remote_create = default_remote_create;
- payload = (void *)&options->remote_callbacks;
+ payload = NULL;
}
if ((error = remote_create(&origin, repo, "origin", url, payload)) < 0)
@@ -328,12 +324,11 @@ static int checkout_branch(git_repository *repo, git_remote *remote, const git_c
return error;
}
-static int clone_into(git_repository *repo, git_remote *_remote, const git_checkout_options *co_opts, const char *branch)
+static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch_options *opts, const git_checkout_options *co_opts, const char *branch)
{
int error;
git_buf reflog_message = GIT_BUF_INIT;
git_remote *remote;
- const git_remote_callbacks *callbacks;
assert(repo && _remote);
@@ -345,18 +340,13 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_check
if ((error = git_remote_dup(&remote, _remote)) < 0)
return error;
- callbacks = git_remote_get_callbacks(_remote);
- if (!giterr__check_version(callbacks, 1, "git_remote_callbacks") &&
- (error = git_remote_set_callbacks(remote, callbacks)) < 0)
- goto cleanup;
-
if ((error = git_remote_add_fetch(remote, "refs/tags/*:refs/tags/*")) < 0)
goto cleanup;
git_remote_set_update_fetchhead(remote, 0);
git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
- if ((error = git_remote_fetch(remote, NULL, git_buf_cstr(&reflog_message))) != 0)
+ if ((error = git_remote_fetch(remote, NULL, opts, git_buf_cstr(&reflog_message))) != 0)
goto cleanup;
error = checkout_branch(repo, remote, co_opts, branch, git_buf_cstr(&reflog_message));
@@ -439,11 +429,11 @@ int git_clone(
if (clone_local == 1)
error = clone_local_into(
- repo, origin, &options.checkout_opts,
+ repo, origin, &options.fetch_opts, &options.checkout_opts,
options.checkout_branch, link);
else if (clone_local == 0)
error = clone_into(
- repo, origin, &options.checkout_opts,
+ repo, origin, &options.fetch_opts, &options.checkout_opts,
options.checkout_branch);
else
error = -1;
@@ -506,7 +496,7 @@ static bool can_link(const char *src, const char *dst, int link)
#endif
}
-static int clone_local_into(git_repository *repo, git_remote *remote, const git_checkout_options *co_opts, const char *branch, int link)
+static int clone_local_into(git_repository *repo, git_remote *remote, const git_fetch_options *fetch_opts, const git_checkout_options *co_opts, const char *branch, int link)
{
int error, flags;
git_repository *src;
@@ -551,7 +541,7 @@ static int clone_local_into(git_repository *repo, git_remote *remote, const git_
git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
- if ((error = git_remote_fetch(remote, NULL, git_buf_cstr(&reflog_message))) != 0)
+ if ((error = git_remote_fetch(remote, NULL, fetch_opts, git_buf_cstr(&reflog_message))) != 0)
goto cleanup;
error = checkout_branch(repo, remote, co_opts, branch, git_buf_cstr(&reflog_message));