summaryrefslogtreecommitdiff
path: root/refspec.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-03-21 01:43:22 -0700
committerJunio C Hamano <gitster@pobox.com>2025-03-21 01:43:22 -0700
commitf543202a16f52f5951a10b2ed6b67d2cd1f1dd17 (patch)
treed0902864af46418619eb2fac9affff5f7c190f5b /refspec.c
parent683c54c999c301c2cd6f715c411407c413b1d84e (diff)
parentc702dd48567cfebca3d4a06b691de97da3f8dc4a (diff)
Merge branch 'jk/fetch-ref-prefix-cleanup' into tb/refspec-fetch-cleanup
* jk/fetch-ref-prefix-cleanup: fetch: use ref prefix list to skip ls-refs fetch: avoid ls-refs only to ask for HEAD symref update fetch: stop protecting additions to ref-prefix list fetch: ask server to advertise HEAD for config-less fetch refspec_ref_prefixes(): clean up refspec_item logic t5516: beef up exact-oid ref prefixes test t5516: drop NEEDSWORK about v2 reachability behavior t5516: prefer "oid" to "sha1" in some test titles t5702: fix typo in test name
Diffstat (limited to 'refspec.c')
-rw-r--r--refspec.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/refspec.c b/refspec.c
index 4cb80b5208..c6ad515f04 100644
--- a/refspec.c
+++ b/refspec.c
@@ -246,14 +246,24 @@ void refspec_ref_prefixes(const struct refspec *rs,
const struct refspec_item *item = &rs->items[i];
const char *prefix = NULL;
- if (item->exact_sha1 || item->negative)
+ if (item->negative)
continue;
- if (rs->fetch == REFSPEC_FETCH)
- prefix = item->src;
- else if (item->dst)
- prefix = item->dst;
- else if (item->src && !item->exact_sha1)
+
+ if (rs->fetch == REFSPEC_FETCH) {
+ if (item->exact_sha1)
+ continue;
prefix = item->src;
+ } else {
+ /*
+ * Pushes can have an explicit destination like
+ * "foo:bar", or can implicitly use the src for both
+ * ("foo" is the same as "foo:foo").
+ */
+ if (item->dst)
+ prefix = item->dst;
+ else if (item->src && !item->exact_sha1)
+ prefix = item->src;
+ }
if (!prefix)
continue;