aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--builtin/fetch.c4
-rwxr-xr-xt/t5503-tagfollow.sh14
2 files changed, 17 insertions, 1 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index fe2b26c74a..a06d130501 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1777,7 +1777,9 @@ static int do_fetch(struct transport *transport,
if (uses_remote_tracking(transport, rs)) {
must_list_refs = 1;
- strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD");
+ if (transport_ls_refs_options.ref_prefixes.nr)
+ strvec_push(&transport_ls_refs_options.ref_prefixes,
+ "HEAD");
}
if (must_list_refs) {
diff --git a/t/t5503-tagfollow.sh b/t/t5503-tagfollow.sh
index 195fc64dd4..845ca43ea0 100755
--- a/t/t5503-tagfollow.sh
+++ b/t/t5503-tagfollow.sh
@@ -160,4 +160,18 @@ test_expect_success 'new clone fetch main and tags' '
test_cmp expect actual
'
+test_expect_success 'fetch specific OID with tag following' '
+ git init --bare clone3.git &&
+ (
+ cd clone3.git &&
+ git remote add origin .. &&
+ git fetch origin $B:refs/heads/main &&
+
+ git -C .. for-each-ref >expect &&
+ git for-each-ref >actual &&
+
+ test_cmp expect actual
+ )
+'
+
test_done