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

[PATCH 1/4] Always perfer annotated tags in git-describe.

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jan 13, 2007, 22:27 UTC
Message-ID
<20070113222752.GA18011@spearce.org>

Several people have suggested that its always better to describe a commit using an annotated tag, and to only use a lightweight tag if absolutely no annotated tag matches the input commit.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 builtin-describe.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/builtin-describe.c b/builtin-describe.c
index a8c98ce..ad672aa 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -138,6 +138,7 @@ static void describe(const char *arg, int last_one)
 	commit_list_insert(cmit, &list);
 	while (list) {
 		struct commit *c = pop_commit(&list);
+		struct commit_list *parents = c->parents;
 		n = match(c);
 		if (n) {
 			struct possible_tag *p = xmalloc(sizeof(*p));
@@ -148,17 +149,17 @@ static void describe(const char *arg, int last_one)
 			else
 				all_matches = p;
 			cur_match = p;
-		} else {
-			struct commit_list *parents = c->parents;
-			while (parents) {
-				struct commit *p = parents->item;
-				parse_commit(p);
-				if (!(p->object.flags & SEEN)) {
-					p->object.flags |= SEEN;
-					insert_by_date(p, &list);
-				}
-				parents = parents->next;
+			if (n->prio == 2)
+				continue;
+		}
+		while (parents) {
+			struct commit *p = parents->item;
+			parse_commit(p);
+			if (!(p->object.flags & SEEN)) {
+				p->object.flags |= SEEN;
+				insert_by_date(p, &list);
 			}
+			parents = parents->next;
 		}
 	}
 
@@ -181,7 +182,8 @@ static void describe(const char *arg, int last_one)
 		while ((!min_match || cur_match->depth < min_match->depth)
 			&& get_revision(&revs))
 			cur_match->depth++;
-		if (!min_match || cur_match->depth < min_match->depth)
+		if (!min_match || (cur_match->depth < min_match->depth
+			&& cur_match->name->prio >= min_match->name->prio))
 			min_match = cur_match;
 		free_commit_list(revs.commits);
 	}
-- 
1.5.0.rc1.g4494
Next: Junio C Hamano
Message 1 of 3 in “Always perfer annotated tags in git-describe.”
  1. 1/4 Always perfer annotated tags in git-describe.Shawn O. Pearce, Jan 13, 2007
  2. Junio C HamanoJan 14, 2007
  3. Junio C HamanoJan 14, 2007

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.