diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-03-05 21:43:04 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-03-05 21:43:04 +0300 |
commit | f3ccd9f0d963a09994e4f934efdd71ea837b6e7b (patch) | |
tree | 10ed6573558622ca1813d76b1866f6a56b3a0e7b /builtin | |
parent | a6b4709302311634a77da8074362475224f6504d (diff) | |
parent | 30b1c7ad9d64695a65c23f922e6ffd2fd35660da (diff) |
Merge branch 'be/describe-multiroot'
"git describe" in a repository with multiple root commits sometimes
gave up looking for the best tag to describe a given commit with
too early, which has been adjusted.
* be/describe-multiroot:
describe: don't abort too early when searching tags
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/describe.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/builtin/describe.c b/builtin/describe.c index b6df81d8d0..420f4c6401 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -376,11 +376,25 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst) if (!(c->object.flags & t->flag_within)) t->depth++; } + /* Stop if last remaining path already covered by best candidate(s) */ if (annotated_cnt && !list) { - if (debug) - fprintf(stderr, _("finished search at %s\n"), - oid_to_hex(&c->object.oid)); - break; + int best_depth = INT_MAX; + unsigned best_within = 0; + for (cur_match = 0; cur_match < match_cnt; cur_match++) { + struct possible_tag *t = &all_matches[cur_match]; + if (t->depth < best_depth) { + best_depth = t->depth; + best_within = t->flag_within; + } else if (t->depth == best_depth) { + best_within |= t->flag_within; + } + } + if ((c->object.flags & best_within) == best_within) { + if (debug) + fprintf(stderr, _("finished search at %s\n"), + oid_to_hex(&c->object.oid)); + break; + } } while (parents) { struct commit *p = parents->item; |