From: Junio C Hamano <gitster@pobox•com>
To: marcnarc@xiplink•com
Cc: git@vger•kernel.org
Subject: Re: [PATCHv4 0/3] fetch: Only call a new ref a "branch" if it's under refs/heads/.
Date: Tue, 17 Apr 2012 08:28:34 -0700 [thread overview]
Message-ID: <7v7gxepecd.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7vbomqpef1.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Tue, 17 Apr 2012 08:26:58 -0700")
From: Marc Branchaud <marcnarc@xiplink•com>
Date: Mon, 16 Apr 2012 18:08:50 -0400
Subject: [PATCH 2/2] fetch: describe new refs based on where it came from
update_local_ref() used to say "[new branch]" when we stored a new ref
outside refs/tags/ hierarchy, but the message is more about what we
fetched, so use the refname at the origin to make that decision.
Also, only call a new ref a "branch" if it's under refs/heads/.
Signed-off-by: Marc Branchaud <marcnarc@xiplink•com>
Signed-off-by: Junio C Hamano <gitster@pobox•com>
---
* And this is a re-roll of yours on top of the updated 1/2; I also
fixed the new test here and there.
builtin/fetch.c | 14 +++++++++++---
t/t5510-fetch.sh | 30 ++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 06d71e4..0f80cf8 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -294,16 +294,24 @@ static int update_local_ref(struct ref *ref,
const char *msg;
const char *what;
int r;
- if (!strncmp(ref->name, "refs/tags/", 10)) {
+ /*
+ * Nicely describe the new ref we're fetching.
+ * Base this on the remote's ref name, as it's
+ * more likely to follow a standard layout.
+ */
+ const char *name = remote_ref ? remote_ref->name : "";
+ if (!prefixcmp(name, "refs/tags/")) {
msg = "storing tag";
what = _("[new tag]");
- }
- else {
+ } else if (!prefixcmp(name, "refs/heads/")) {
msg = "storing head";
what = _("[new branch]");
if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
(recurse_submodules != RECURSE_SUBMODULES_ON))
check_for_new_submodule_commits(ref->new_sha1);
+ } else {
+ msg = "storing ref";
+ what = _("[new ref]");
}
r = s_update_ref(msg, ref, 0);
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 308c02e..d7a19a1 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -162,6 +162,36 @@ test_expect_success 'fetch following tags' '
'
+test_expect_success 'fetch uses remote ref names to describe new refs' '
+ cd "$D" &&
+ git init descriptive &&
+ (
+ cd descriptive &&
+ git config remote.o.url .. &&
+ git config remote.o.fetch "refs/heads/*:refs/crazyheads/*" &&
+ git config --add remote.o.fetch "refs/others/*:refs/heads/*" &&
+ git fetch o
+ ) &&
+ git tag -a -m "Descriptive tag" descriptive-tag &&
+ git branch descriptive-branch &&
+ git checkout descriptive-branch &&
+ echo "Nuts" >crazy &&
+ git add crazy &&
+ git commit -a -m "descriptive commit" &&
+ git update-ref refs/others/crazy HEAD &&
+ (
+ cd descriptive &&
+ git fetch o 2>actual &&
+ grep " -> refs/crazyheads/descriptive-branch$" actual |
+ test_i18ngrep "new branch" &&
+ grep " -> descriptive-tag$" actual |
+ test_i18ngrep "new tag" &&
+ grep " -> crazy$" actual |
+ test_i18ngrep "new ref"
+ ) &&
+ git checkout master
+'
+
test_expect_success 'fetch must not resolve short tag name' '
cd "$D" &&
--
1.7.10.332.g1863c
next prev parent reply other threads:[~2012-04-17 15:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-13 17:08 [PATCHv2] fetch: Only call a new ref a "branch" if it's under refs/heads/ marcnarc
2012-04-13 20:07 ` Jonathan Nieder
2012-04-16 14:26 ` Marc Branchaud
2012-04-13 21:13 ` Jeff King
2012-04-13 21:53 ` Jonathan Nieder
2012-04-13 22:39 ` Junio C Hamano
2012-04-16 14:58 ` Marc Branchaud
2012-04-16 15:00 ` Jeff King
2012-04-16 15:52 ` [PATCHv3] fetch: Use the remote's ref name to decide how to describe new refs marcnarc
2012-04-16 16:10 ` Jonathan Nieder
2012-04-16 17:59 ` Junio C Hamano
2012-04-16 20:21 ` Marc Branchaud
2012-04-16 22:08 ` [PATCHv4 0/3] fetch: Only call a new ref a "branch" if it's under refs/heads/ marcnarc
2012-04-16 22:08 ` [PATCH 1/3] submodules: recursive fetch also checks new tags for submodule commits marcnarc
2012-04-16 22:08 ` [PATCH 2/3] fetch: Pass both the full remote ref and its short name to update_local_ref() marcnarc
2012-04-16 22:08 ` [PATCH 3/3] fetch: Use the remote's ref name to decide how to describe new refs marcnarc
2012-04-16 22:34 ` Jonathan Nieder
2012-04-17 7:53 ` Zbigniew Jędrzejewski-Szmek
2012-04-17 7:57 ` Jonathan Nieder
2012-04-17 8:39 ` Zbigniew Jędrzejewski-Szmek
2012-04-17 14:23 ` Marc Branchaud
2012-04-17 15:18 ` Jonathan Nieder
2012-04-17 15:26 ` [PATCHv4 0/3] fetch: Only call a new ref a "branch" if it's under refs/heads/ Junio C Hamano
2012-04-17 15:28 ` Junio C Hamano [this message]
2012-04-17 19:30 ` Marc Branchaud
2012-04-17 22:29 ` Jeff King
2012-04-16 16:08 ` [PATCHv2] " Jonathan Nieder
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=7v7gxepecd.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=marcnarc@xiplink$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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