Skip to content

Commit 5d55ad0

Browse files
committed
Merge branch 'tb/fetch-follow-tags-fix'
* tb/fetch-follow-tags-fix: fetch: fix following tags when fetching specific OID
2 parents a36e024 + bd52d9a commit 5d55ad0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

builtin/fetch.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,9 @@ static int do_fetch(struct transport *transport,
17771777

17781778
if (uses_remote_tracking(transport, rs)) {
17791779
must_list_refs = 1;
1780-
strvec_push(&transport_ls_refs_options.ref_prefixes, "HEAD");
1780+
if (transport_ls_refs_options.ref_prefixes.nr)
1781+
strvec_push(&transport_ls_refs_options.ref_prefixes,
1782+
"HEAD");
17811783
}
17821784

17831785
if (must_list_refs) {

t/t5503-tagfollow.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,18 @@ test_expect_success 'new clone fetch main and tags' '
160160
test_cmp expect actual
161161
'
162162

163+
test_expect_success 'fetch specific OID with tag following' '
164+
git init --bare clone3.git &&
165+
(
166+
cd clone3.git &&
167+
git remote add origin .. &&
168+
git fetch origin $B:refs/heads/main &&
169+
170+
git -C .. for-each-ref >expect &&
171+
git for-each-ref >actual &&
172+
173+
test_cmp expect actual
174+
)
175+
'
176+
163177
test_done

0 commit comments

Comments
 (0)