Skip to content

Commit 81dc223

Browse files
spearcegitster
authored andcommitted
describe: Avoid unnecessary warning when using --all
In 212945d ("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. Patch-by: René Scharfe <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4ed19a3 commit 81dc223

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

builtin-describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static void display_name(struct commit_name *n)
160160
n->tag = lookup_tag(n->sha1);
161161
if (!n->tag || parse_tag(n->tag) || !n->tag->tag)
162162
die("annotated tag %s not available", n->path);
163-
if (strcmp(n->tag->tag, n->path))
163+
if (strcmp(n->tag->tag, all ? n->path + 5 : n->path))
164164
warning("tag '%s' is really '%s' here", n->tag->tag, n->path);
165165
}
166166

t/t6120-describe.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ check_describe B --tags HEAD^^2^
100100
check_describe B-0-* --long HEAD^^2^
101101
check_describe A-3-* --long HEAD^^2
102102

103+
: >err.expect
104+
check_describe A --all A^0
105+
test_expect_success 'no warning was displayed for A' '
106+
test_cmp err.expect err.actual
107+
'
108+
103109
test_expect_success 'rename tag A to Q locally' '
104110
mv .git/refs/tags/A .git/refs/tags/Q
105111
'

0 commit comments

Comments
 (0)