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@xxxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html