Thread (8 messages) flat view 8 messages, 3 authors, 2016-06-15
STALE3751d

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

From: Sam Vilain <hidden>
Date: 2016-06-15 22:47:46
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help