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

[PATCH 3/4] fetch --use-mirror: don't fetch with 'autotags' for actual fetch

From
Sam Vilain <sam@vilain.net>
Date
Nov 25, 2009, 10:06 UTC
Message-ID
<1259143617-26580-4-git-send-email-sam@vilain.net>
In-Reply-To
<1259143617-26580-3-git-send-email-sam@vilain.net>

Unsetting 'autotags' at a late stage during the fetch process has the useful behaviour of figuring out which refs to fetch where according to the regular autotags rules, building a refspec (struct ref* linked list), and then we turn them off for mirror fetch and no real tags are actually changed, just the re-written ones under refs/mirrors/. The final fetch will re-set autotags again, and uncannily the exact behaviour we are after springs up: we get all the tags for the refs that are now changing, even though we got the data from a mirror. All from one line of code. Win!

Signed-off-by: Sam Vilain <sam@vilain.net>
---
 builtin-fetch.c         |    1 +
 t/t5560-mirror-fetch.sh |   12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/builtin-fetch.c b/builtin-fetch.c
index b3b8766..daa287a 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -269,6 +269,7 @@ static struct ref *get_ref_map(struct transport *transport,
 		find_non_local_tags(transport, &ref_map, &tail);
 	ref_remove_duplicates(ref_map);
 	if (strcmp(transport->url, transport->remote->url[0]) != 0) {
+		*autotags = 0;
 		return mirror_refmap(transport, ref_map);
 	}
 
diff --git a/t/t5560-mirror-fetch.sh b/t/t5560-mirror-fetch.sh
index 940dc0e..58d5f3c 100644
--- a/t/t5560-mirror-fetch.sh
+++ b/t/t5560-mirror-fetch.sh
@@ -11,11 +11,13 @@ test_expect_success setup '
 	echo >file master initial &&
 	git add file &&
 	git commit -a -m "Master initial" &&
+	git tag -m "SEEN" initial &&
 	git clone . master &&
 	git clone master mirror &&
 	cd master &&
 	echo >file master update &&
 	git commit -a -m "Master update" &&
+	git tag -m "SEEN" update &&
 	cd .. &&
 	mkdir clone &&
 	cd clone &&
@@ -35,12 +37,20 @@ test_expect_success 'fetch using mirror - explicit' '
 
 test_expect_success 'fetch using mirror - default' '
 	cd .. &&
+	cd mirror &&
+	git tag -m "badtag" badtag &&
+	cd .. &&
 	mkdir clone2 &&
 	cd clone2 &&
 	git init &&
 	git remote add origin ../master &&
 	git config remote.origin.mirror-url ../mirror
 	git fetch --use-mirror &&
-	git rev-parse refs/mirrors/origin/localhost/heads/master
+	git rev-parse refs/mirrors/origin/localhost/heads/master &&
+	git rev-parse refs/mirrors/origin/localhost/tags/initial &&
+	! git rev-parse refs/tags/badtag &&
+	git rev-parse refs/tags/initial &&
+	git rev-parse refs/tags/update
 '
+
 test_done
-- 
1.6.3.3
Previous: Sam VilainNext: Sam Vilain
Message 4 of 8 in “Client-side mirroring patches (v0)”
  1. Sam VilainNov 25, 2009
  2. 1/4 remote: allow mirroring to be specified, and document settingsSam Vilain, Nov 25, 2009
  3. 2/4 fetch: try mirrors if selectedSam Vilain, Nov 25, 2009
  4. 3/4 fetch --use-mirror: don't fetch with 'autotags' for actual fetchSam Vilain, Nov 25, 2009
  5. 4/4 fetch: cleanup refs with --use-mirrorSam Vilain, Nov 25, 2009
  6. Shawn O. PearceNov 26, 2009
  7. Shawn O. PearceNov 26, 2009
  8. Nanako ShiraishiJan 1, 2010

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.