Skip to contentSkip to conversation

describe: Avoid unnecessary warning when using --all

PATCH In review Shawn O. Pearce 3 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 describe: Avoid unnecessary warning when using --all

In 212945d4 ("Teach git-describe to verify annotated tag names before output") git-describe learned how to output a warning if an annotated tag object was matched but its internal name doesn't match the local ref name.

However, "git describe --all" causes the local ref name to be prefixed with "tags/", so we need to skip over this prefix before comparing the local ref name with the name recorded inside of the tag object.

---
IMHO, suitable for maint...

 builtin-describe.c  |    2 +-
 t/t6120-describe.sh |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)
builtin-describe.c +1 -1
index d2cfb1b..3a007ed 100644
@@ -158,7 +158,7 @@ static void display_name(struct commit_name *n)
 		n->tag = lookup_tag(n->sha1);
 		if (!n->tag || parse_tag(n->tag) || !n->tag->tag)
 			die("annotated tag %s not available", n->path);
-		if (strcmp(n->tag->tag, n->path))
+		if (strcmp(n->tag->tag, all ? n->path + 5 : n->path))
 			warning("tag '%s' is really '%s' here", n->tag->tag, n->path);
 	}
 
t/t6120-describe.sh +6 -0
index e6c9e59..8c7e081 100755
@@ -100,6 +100,12 @@ check_describe B --tags HEAD^^2^
 check_describe B-0-* --long HEAD^^2^
 check_describe A-3-* --long HEAD^^2
 
+: >err.expect
+check_describe A --all A^0
+test_expect_success 'no warning was displayed for A' '
+	test_cmp err.expect err.actual
+'
+
 test_expect_success 'rename tag A to Q locally' '
 	mv .git/refs/tags/A .git/refs/tags/Q
 '
Signature · 1 line
1.6.1.302.gccd4d
#1 lore raw
Quoted 10 lines · Shawn O. Pearce

In 212945d4 ("Teach git-describe to verify annotated tag names before output") git-describe learned how to output a warning if an annotated tag object was matched but its internal name doesn't match the local ref name.

However, "git describe --all" causes the local ref name to be prefixed with "tags/", so we need to skip over this prefix before comparing the local ref name with the name recorded inside of the tag object.

Quoted 4 lines

---
IMHO, suitable for maint...

Yeah, do you prefer to be known as "sop" over "spearce" these days, by the way? It does not make a difference to me but I just noticed that Author and S-o-b won't be matching, so I am just being curious.

#2 lore raw
Quoted 7 lines · Junio C Hamano
Quoted 2 lines · Shawn O. Pearce

Yeah, do you prefer to be known as "sop" over "spearce" these days, by the way? It does not make a difference to me but I just noticed that Author and S-o-b won't be matching, so I am just being curious.

Whoops.

I use [email protected] for my Git work so the S-o-b line above is wrong. I just fixed it in my development repository on the work system I used to make this patch.

Having two personalities is hard... ;-)

Can you please amend to use my normal [email protected] address?

Signature · 1 line
Shawn.
#3 lore raw
Quoted 3 lines · Shawn O. Pearce

Having two personalities is hard... ;-)

Can you please amend to use my normal [email protected] address?

BTW, what Pasky/Nice did was to keep the author field the same, but change the S-o-b line based on if they did it in their free time or in work hours.

Like this one:

http://article.gmane.org/gmane.comp.version-control.git/97419

And the related thread:

http://thread.gmane.org/gmane.comp.version-control.git/96690/focus=96768

#4 lore raw
Quoted 6 lines · Miklos Vajna
Quoted 3 lines · Shawn O. Pearce

Having two personalities is hard... ;-)

Can you please amend to use my normal [email protected] address?

BTW, what Pasky/Nice did was to keep the author field the same, but

Err, I meant to mention Nico, sorry.