summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-04-22 16:11:10 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-05-13 09:46:36 +0200
commit3eff2a57289ec19b1a805dd938299d1dcae47097 (patch)
tree3bd01239ee483c5a8d60768228d9968f2ff90611 /src
parent058b753ceb8f6b25b77e57106b3a87997bc6362a (diff)
downloadlibgit2-3eff2a57289ec19b1a805dd938299d1dcae47097.tar.gz
remote: move the update_fetchhead setting to the options
While this will rarely be different from the default, having it in the remote adds yet another setting it has to keep around and can affect its behaviour. Move it to the options.
Diffstat (limited to 'src')
-rw-r--r--src/clone.c6
-rw-r--r--src/remote.c28
-rw-r--r--src/remote.h1
3 files changed, 13 insertions, 22 deletions
diff --git a/src/clone.c b/src/clone.c
index 53cdae673..7dcbb8a1d 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -328,6 +328,7 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch
{
int error;
git_buf reflog_message = GIT_BUF_INIT;
+ git_fetch_options fetch_opts;
git_remote *remote;
assert(repo && _remote);
@@ -343,10 +344,11 @@ static int clone_into(git_repository *repo, git_remote *_remote, const git_fetch
if ((error = git_remote_add_fetch(remote, "refs/tags/*:refs/tags/*")) < 0)
goto cleanup;
- git_remote_set_update_fetchhead(remote, 0);
+ memcpy(&fetch_opts, opts, sizeof(git_fetch_options));
+ fetch_opts.update_fetchhead = 0;
git_buf_printf(&reflog_message, "clone: from %s", git_remote_url(remote));
- if ((error = git_remote_fetch(remote, NULL, opts, 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));
diff --git a/src/remote.c b/src/remote.c
index 95c316f54..c4f5e0ff9 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -159,7 +159,6 @@ static int create_internal(git_remote **out, git_repository *repo, const char *n
GITERR_CHECK_ALLOC(remote);
remote->repo = repo;
- remote->update_fetchhead = 1;
if (git_vector_init(&remote->refs, 32, NULL) < 0 ||
canonicalize_url(&canonical_url, url) < 0)
@@ -311,7 +310,6 @@ int git_remote_dup(git_remote **dest, git_remote *source)
remote->repo = source->repo;
remote->download_tags = source->download_tags;
- remote->update_fetchhead = source->update_fetchhead;
remote->prune_refs = source->prune_refs;
if (git_vector_init(&remote->refs, 32, NULL) < 0 ||
@@ -401,7 +399,6 @@ int git_remote_lookup(git_remote **out, git_repository *repo, const char *name)
remote = git__calloc(1, sizeof(git_remote));
GITERR_CHECK_ALLOC(remote);
- remote->update_fetchhead = 1;
remote->name = git__strdup(name);
GITERR_CHECK_ALLOC(remote->name);
@@ -972,7 +969,7 @@ int git_remote_fetch(
const git_fetch_options *opts,
const char *reflog_message)
{
- int error;
+ int error, update_fetchhead = 1;
bool prune = false;
git_buf reflog_msg_buf = GIT_BUF_INIT;
const git_remote_callbacks *cbs = NULL;
@@ -980,6 +977,7 @@ int git_remote_fetch(
if (opts) {
GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks");
cbs = &opts->callbacks;
+ update_fetchhead = opts->update_fetchhead;
}
/* Connect and download everything */
@@ -1004,7 +1002,7 @@ int git_remote_fetch(
}
/* Create "remote/foo" branches for all remote branches */
- error = git_remote_update_tips(remote, cbs, git_buf_cstr(&reflog_msg_buf));
+ error = git_remote_update_tips(remote, cbs, update_fetchhead, git_buf_cstr(&reflog_msg_buf));
git_buf_free(&reflog_msg_buf);
if (error < 0)
return error;
@@ -1320,6 +1318,7 @@ cleanup:
static int update_tips_for_spec(
git_remote *remote,
const git_remote_callbacks *callbacks,
+ int update_fetchhead,
git_refspec *spec,
git_vector *refs,
const char *log_message)
@@ -1408,7 +1407,7 @@ static int update_tips_for_spec(
}
}
- if (git_remote_update_fetchhead(remote) &&
+ if (update_fetchhead &&
(error = git_remote_write_fetchhead(remote, spec, &update_heads)) < 0)
goto on_error;
@@ -1519,6 +1518,7 @@ static int opportunistic_updates(const git_remote *remote, git_vector *refs, con
int git_remote_update_tips(
git_remote *remote,
const git_remote_callbacks *callbacks,
+ int update_fetchhead,
const char *reflog_message)
{
git_refspec *spec, tagspec;
@@ -1539,7 +1539,7 @@ int git_remote_update_tips(
goto out;
if (remote->download_tags == GIT_REMOTE_DOWNLOAD_TAGS_ALL) {
- if ((error = update_tips_for_spec(remote, callbacks, &tagspec, &refs, reflog_message)) < 0)
+ if ((error = update_tips_for_spec(remote, callbacks, update_fetchhead, &tagspec, &refs, reflog_message)) < 0)
goto out;
}
@@ -1547,7 +1547,7 @@ int git_remote_update_tips(
if (spec->push)
continue;
- if ((error = update_tips_for_spec(remote, callbacks, spec, &refs, reflog_message)) < 0)
+ if ((error = update_tips_for_spec(remote, callbacks, update_fetchhead, spec, &refs, reflog_message)) < 0)
goto out;
}
@@ -1948,16 +1948,6 @@ cleanup:
return error;
}
-int git_remote_update_fetchhead(git_remote *remote)
-{
- return (remote->update_fetchhead != 0);
-}
-
-void git_remote_set_update_fetchhead(git_remote *remote, int value)
-{
- remote->update_fetchhead = (value != 0);
-}
-
int git_remote_is_valid_name(
const char *remote_name)
{
@@ -2414,7 +2404,7 @@ int git_remote_push(git_remote *remote, const git_strarray *refspecs, const git_
if ((error = git_remote_upload(remote, refspecs, opts)) < 0)
return error;
- error = git_remote_update_tips(remote, cbs, NULL);
+ error = git_remote_update_tips(remote, cbs, 0, NULL);
git_remote_disconnect(remote);
return error;
diff --git a/src/remote.h b/src/remote.h
index 3a5c0dee4..e696997f4 100644
--- a/src/remote.h
+++ b/src/remote.h
@@ -30,7 +30,6 @@ struct git_remote {
git_transfer_progress stats;
unsigned int need_pack;
git_remote_autotag_option_t download_tags;
- int update_fetchhead;
int prune_refs;
int passed_refspecs;
};