threads / patch / 6365

patch, 4 partsAlways perfer annotated tags in git-describe.

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

## tl;dr

3 messages between Jan 13, 2007 and Jan 14, 2007. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Shawn O. Pearce· Jan 13, 2007, 22:27 UTC · lore

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(-)
Show changes to builtin-describe.c +13 −11
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
Junio C Hamano· Jan 14, 2007, 19:11 UTC · re: Shawn O. Pearce · lore

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

"Shawn O. Pearce" <spearce@spearce.org> writes:
Show 6 quoted lines
> @@ -148,17 +149,17 @@ static void describe(const char *arg, int last_one)
>  			else
>  				all_matches = p;
>  			cur_match = p;
> +			if (n->prio == 2)
> +				continue;

When you do not have _any_ annotated tag but you do have lightweight tags, wouldn't this make the traversal go all the way down to root?

Junio C Hamano· Jan 14, 2007, 21:36 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <junkio@cox.net> writes:
Show 12 quoted lines
> "Shawn O. Pearce" <spearce@spearce.org> writes:
>
>> @@ -148,17 +149,17 @@ static void describe(const char *arg, int last_one)
>>  			else
>>  				all_matches = p;
>>  			cur_match = p;
>> +			if (n->prio == 2)
>> +				continue;
>
> When you do not have _any_ annotated tag but you do have
> lightweight tags, wouldn't this make the traversal go all the
> way down to root?
This is irrelevant now.  Please ignore.

← back to recent threads