Always perfer annotated tags in git-describe.
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> Signed-off-by: Junio C Hamano <junkio@cox.net>
Shawn O. Pearce committed
Jan 13, 2007 at 17:27 UTC
dccd0c2abdb958daf6f168ba925b67441dc6be61
1 file changed
+13
-11
builtin-describe.c
+13
-11
@@ -138,6 +138,7 @@ static void describe(const char *arg, int last_one)
138
commit_list_insert(cmit, &list);
139
while (list) {
140
struct commit *c = pop_commit(&list);
141
+ struct commit_list *parents = c->parents;
142
n = match(c);
143
if (n) {
144
struct possible_tag *p = xmalloc(sizeof(*p));
@@ -148,17 +149,17 @@ static void describe(const char *arg, int last_one)
149
else
150
all_matches = p;
151
cur_match = p;
151
- } else {
152
- struct commit_list *parents = c->parents;
153
- while (parents) {
154
- struct commit *p = parents->item;
155
- parse_commit(p);
156
- if (!(p->object.flags & SEEN)) {
157
- p->object.flags |= SEEN;
158
- insert_by_date(p, &list);
159
- }
160
- parents = parents->next;
152
+ if (n->prio == 2)
153
+ continue;
154
+ }
155
+ while (parents) {
156
+ struct commit *p = parents->item;
157
+ parse_commit(p);
158
+ if (!(p->object.flags & SEEN)) {
159
+ p->object.flags |= SEEN;
160
+ insert_by_date(p, &list);
161
}
162
+ parents = parents->next;
163
}
164
}
165
@@ -181,7 +182,8 @@ static void describe(const char *arg, int last_one)
182
while ((!min_match || cur_match->depth < min_match->depth)
183
&& get_revision(&revs))
184
cur_match->depth++;
184
- if (!min_match || cur_match->depth < min_match->depth)
185
+ if (!min_match || (cur_match->depth < min_match->depth
186
+ && cur_match->name->prio >= min_match->name->prio))
187
min_match = cur_match;
188
free_commit_list(revs.commits);
189
}