summaryrefslogtreecommitdiffstats
path: root/builtin/fetch.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-12-19 19:58:28 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-19 19:58:28 +0100
commitae75cefd94075045edeb1d23283a47e4e48a9360 (patch)
tree04a340ed0710c79f612de660b2eb18e2151e4491 /builtin/fetch.c
parentMerge branch 'bf/set-head-symref' (diff)
parentfetch: do not ask for HEAD unnecessarily (diff)
downloadgit-ae75cefd94075045edeb1d23283a47e4e48a9360.tar.xz
git-ae75cefd94075045edeb1d23283a47e4e48a9360.zip
Merge branch 'jc/set-head-symref-fix'
"git fetch" from a configured remote learned to update a missing remote-tracking HEAD but it asked the remote about their HEAD even when it did not need to, which has been corrected. Incidentally, this also corrects "git fetch --tags $URL" which was broken by the new feature in an unspecified way. * jc/set-head-symref-fix: fetch: do not ask for HEAD unnecessarily
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r--builtin/fetch.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index fe05000c9e..f5eb2cf338 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1640,6 +1640,21 @@ cleanup:
return result;
}
+static int uses_remote_tracking(struct transport *transport, struct refspec *rs)
+{
+ if (!remote_is_configured(transport->remote, 0))
+ return 0;
+
+ if (!rs->nr)
+ rs = &transport->remote->fetch;
+
+ for (int i = 0; i < rs->nr; i++)
+ if (rs->items[i].dst)
+ return 1;
+
+ return 0;
+}
+
static int do_fetch(struct transport *transport,
struct refspec *rs,
const struct fetch_config *config)
@@ -1709,7 +1724,10 @@ static int do_fetch(struct transport *transport,
"refs/tags/");
}
- strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD");
+ if (uses_remote_tracking(transport, rs)) {
+ must_list_refs = 1;
+ strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD");
+ }
if (must_list_refs) {
trace2_region_enter("fetch", "remote_refs", the_repository);