git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] clone --mirror: avoid storing repeated tags

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 8, 2008, 02:29 UTC
Message-ID
<alpine.DEB.1.00.0808080428520.9611@pacific.mpi-cbg.de.mpi-cbg.de>
In-Reply-To
<489B9A8B.9050807@cesarb.net>

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>
---
 builtin-clone.c  |    3 ++-
 t/t5601-clone.sh |   12 ++++++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/builtin-clone.c b/builtin-clone.c
index 8612d59..c0e3086 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -330,7 +330,8 @@ static struct ref *write_remote_refs(const struct ref *refs,
 	struct ref *r;
 
 	get_fetch_map(refs, refspec, &tail, 0);
-	get_fetch_map(refs, tag_refspec, &tail, 0);
+	if (!option_mirror)
+		get_fetch_map(refs, tag_refspec, &tail, 0);
 
 	for (r = local_refs; r; r = r->next)
 		add_extra_ref(r->peer_ref->name, r->old_sha1, 0);
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index a13b6f9..59c65fe 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -95,4 +95,16 @@ test_expect_success 'clone --bare names the local repository <name>.git' '
 
 '
 
+test_expect_success 'clone --mirror does not repeat tags' '
+
+	(cd src &&
+	 git tag some-tag HEAD) &&
+	git clone --mirror src mirror2 &&
+	(cd mirror2 &&
+	 git show-ref 2> clone.err > clone.out) &&
+	test_must_fail grep Duplicate mirror2/clone.err &&
+	grep some-tag mirror2/clone.out
+
+'
+
 test_done
-- 
1.6.0.rc1.112.gebbe4
Previous: Cesar Eduardo BarrosNext: Junio C Hamano
Message 2 of 4 in “1.6.0.rc2: Duplicated refs when using git clone --mirror”
  1. Cesar Eduardo BarrosAug 8, 2008
  2. clone --mirror: avoid storing repeated tagsJohannes Schindelin, Aug 8, 2008
  3. Junio C HamanoAug 8, 2008
  4. Junio C HamanoAug 8, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.