Skip to content

Commit 468386a

Browse files
dschogitster
authored andcommitted
clone --mirror: avoid storing repeated tags
With --mirror, clone asks for refs/* already, so it does not need to ask for ref/tags/*, too. Noticed by Cesar Eduardo Barros. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1fdf6ee commit 468386a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

builtin-clone.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ static struct ref *write_remote_refs(const struct ref *refs,
330330
struct ref *r;
331331

332332
get_fetch_map(refs, refspec, &tail, 0);
333-
get_fetch_map(refs, tag_refspec, &tail, 0);
333+
if (!option_mirror)
334+
get_fetch_map(refs, tag_refspec, &tail, 0);
334335

335336
for (r = local_refs; r; r = r->next)
336337
add_extra_ref(r->peer_ref->name, r->old_sha1, 0);

t/t5601-clone.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,16 @@ test_expect_success 'clone --bare names the local repository <name>.git' '
9595
9696
'
9797

98+
test_expect_success 'clone --mirror does not repeat tags' '
99+
100+
(cd src &&
101+
git tag some-tag HEAD) &&
102+
git clone --mirror src mirror2 &&
103+
(cd mirror2 &&
104+
git show-ref 2> clone.err > clone.out) &&
105+
test_must_fail grep Duplicate mirror2/clone.err &&
106+
grep some-tag mirror2/clone.out
107+
108+
'
109+
98110
test_done

0 commit comments

Comments
 (0)