git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] describe: do not use unannotated tag even if exact match

From
Thomas Rast <trast@student.ethz.ch>
Date
Nov 18, 2009, 13:32 UTC
Message-ID
<985ab43f219852a6d5dc302424fd1c012e19a09e.1258551042.git.trast@student.ethz.ch>

4d23660 (describe: when failing, tell the user about options that work, 2009-10-28) forgot to update the shortcut path where the code detected and used a possible exact match. This means that an unannotated tag on HEAD would be used by 'git describe'.

Guard this code path against the new circumstances, where unannotated tags can be present in ->util even if we're not actually planning to use them.

While there, also add some tests for --all.
Reported by 'yashi' on IRC.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 builtin-describe.c  |    2 +-
 t/t6120-describe.sh |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/builtin-describe.c b/builtin-describe.c
index d4efb10..71be2a9 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -200,7 +200,7 @@ static void describe(const char *arg, int last_one)
 		die("%s is not a valid '%s' object", arg, commit_type);
 
 	n = cmit->util;
-	if (n) {
+	if (n && (tags || all || n->prio == 2)) {
 		/*
 		 * Exact match to an existing ref.
 		 */
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index c050f94..065dead 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -92,12 +92,18 @@ check_describe A-* HEAD^
 check_describe D-* HEAD^^
 check_describe A-* HEAD^^2
 check_describe B HEAD^^2^
+check_describe D-* HEAD^^^
 
 check_describe c-* --tags HEAD
 check_describe c-* --tags HEAD^
 check_describe e-* --tags HEAD^^
 check_describe c-* --tags HEAD^^2
 check_describe B --tags HEAD^^2^
+check_describe e --tags HEAD^^^
+
+check_describe heads/master --all HEAD
+check_describe tags/c-* --all HEAD^
+check_describe tags/e --all HEAD^^^
 
 check_describe B-0-* --long HEAD^^2^
 check_describe A-3-* --long HEAD^^2
-- 
1.6.5.3.381.gfeb7e
Message 1 of 1 in “describe: do not use unannotated tag even if exact match”
  1. describe: do not use unannotated tag even if exact matchThomas Rast, Nov 18, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.