aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/fetch.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2025-03-18 01:41:22 -0400
committerJunio C Hamano <gitster@pobox.com>2025-03-18 12:21:26 -0700
commitaab0f899d9349bed824bf545b7398ab16c27a204 (patch)
tree16eb4fbbc762473684498e3692822ec714c487d9 /builtin/fetch.c
parentfetch: only respect followRemoteHEAD with configured refspecs (diff)
downloadgit-aab0f899d9349bed824bf545b7398ab16c27a204.tar.gz
git-aab0f899d9349bed824bf545b7398ab16c27a204.zip
fetch: don't ask for remote HEAD if followRemoteHEAD is "never"
When we are going to consider updating the refs/remotes/*/HEAD symref, we have to ask the remote side where its HEAD points. But if we know that the feature is disabled by config, we don't need to bother! This saves a little bit of work and network communication for the server. And even a little bit of effort on the client, as our local set_head() function did a bit of work matching the remote HEAD before realizing that we're not going to do anything with it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r--builtin/fetch.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 66f5ae31b6..3658509740 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1643,9 +1643,6 @@ static int set_head(const struct ref *remote_refs, struct remote *remote)
string_list_append(&heads, strip_refshead(ref->name));
}
- if (follow_remote_head == FOLLOW_REMOTE_NEVER)
- goto cleanup;
-
if (!heads.nr)
result = 1;
else if (heads.nr > 1)
@@ -1729,7 +1726,8 @@ static int do_fetch(struct transport *transport,
if (transport->remote->fetch.nr) {
refspec_ref_prefixes(&transport->remote->fetch,
&transport_ls_refs_options.ref_prefixes);
- do_set_head = 1;
+ if (transport->remote->follow_remote_head != FOLLOW_REMOTE_NEVER)
+ do_set_head = 1;
}
if (branch_has_merge_config(branch) &&
!strcmp(branch->remote_name, transport->remote->name)) {