Skip to content

Commit 1bba001

Browse files
knittlgitster
authored andcommitted
describe: prepend "tags/" when describing tags with embedded name
The man page of the "git describe" command explains the expected output when using the --all option, i.e. the full reference path is shown, including heads/ or tags/ prefix. When 212945d ("Teach git-describe to verify annotated tag names before output") made Git favor the embedded name of annotated tags, it accidentally changed the output format when the --all flag is given, only printing the tag's name without the prefix. Check if --all was specified and re-add the "tags/" prefix for this special case to fix the regresssion. Signed-off-by: Daniel Knittl-Frank <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3013dff commit 1bba001

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

builtin/describe.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,13 @@ static void display_name(struct commit_name *n)
271271
n->name_checked = 1;
272272
}
273273

274-
if (n->tag)
274+
if (n->tag) {
275+
if (all)
276+
printf("tags/");
275277
printf("%s", n->tag->tag);
276-
else
278+
} else {
277279
printf("%s", n->path);
280+
}
278281
}
279282

280283
static void show_suffix(int depth, const struct object_id *oid)

t/t6120-describe.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ test_expect_success 'describe --contains defaults to HEAD without commit-ish' '
122122
'
123123

124124
: >err.expect
125-
check_describe A --all A^0
125+
check_describe tags/A --all A^0
126126
test_expect_success 'no warning was displayed for A' '
127127
test_cmp err.expect err.actual
128128
'
@@ -340,4 +340,8 @@ test_expect_success ULIMIT_STACK_SIZE 'describe works in a deep repo' '
340340
test_cmp expect actual
341341
'
342342

343+
check_describe tags/A --all A
344+
check_describe tags/c --all c
345+
check_describe heads/branch_A --all --match='branch_*' branch_A
346+
343347
test_done

0 commit comments

Comments
 (0)