From: Sam Vilain <sam@vilain.net>
To: git@vger.kernel.org
Cc: Sam Vilain <sam@vilain.net>
Subject: [PATCH 3/4] fetch --use-mirror: don't fetch with 'autotags' for actual fetch
Date: Wed, 25 Nov 2009 23:06:56 +1300 [thread overview]
Message-ID: <1259143617-26580-4-git-send-email-sam@vilain.net> (raw)
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
next prev parent reply other threads:[~2009-11-25 10:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-25 10:06 Client-side mirroring patches (v0) Sam Vilain
2009-11-25 10:06 ` [PATCH 1/4] remote: allow mirroring to be specified, and document settings Sam Vilain
2009-11-25 10:06 ` [PATCH 2/4] fetch: try mirrors if selected Sam Vilain
2009-11-25 10:06 ` Sam Vilain [this message]
2009-11-25 10:06 ` [PATCH 4/4] fetch: cleanup refs with --use-mirror Sam Vilain
2009-11-26 1:20 ` [PATCH 2/4] fetch: try mirrors if selected Shawn O. Pearce
2009-11-26 0:58 ` Client-side mirroring patches (v0) Shawn O. Pearce
2010-01-01 0:05 ` Nanako Shiraishi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1259143617-26580-4-git-send-email-sam@vilain.net \
--to=sam@vilain.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox