aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/describe.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-12-15 17:54:25 -0800
committerJunio C Hamano <gitster@pobox.com>2024-12-15 17:54:25 -0800
commit73b7e03e9e4fdd3e09c08ff9c2d215bcabc19f34 (patch)
treef7c84cac7912e5c8a9aec915d1afe02be4f43948 /builtin/describe.c
parent2ccc89b0c16c51561da90d21cfbb4b58cc877bf6 (diff)
parentdb162862b36f8c2de8e7020801870abf33b61a20 (diff)
downloadgit-73b7e03e9e4fdd3e09c08ff9c2d215bcabc19f34.tar.gz
Merge branch 'jk/describe-perf'
"git describe" optimization. * jk/describe-perf: describe: split "found all tags" and max_candidates logic describe: stop traversing when we run out of names describe: stop digging for max_candidates+1 t/perf: add tests for git-describe t6120: demonstrate weakness in disjoint-root handling
Diffstat (limited to 'builtin/describe.c')
-rw-r--r--builtin/describe.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/builtin/describe.c b/builtin/describe.c
index 7330a77b38..a6ef8af32a 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -366,6 +366,13 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
struct commit_name **slot;
seen_commits++;
+
+ if (match_cnt == max_candidates ||
+ match_cnt == hashmap_get_size(&names)) {
+ gave_up_on = c;
+ break;
+ }
+
slot = commit_names_peek(&commit_names, c);
n = slot ? *slot : NULL;
if (n) {
@@ -381,10 +388,6 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
if (n->prio == 2)
annotated_cnt++;
}
- else {
- gave_up_on = c;
- break;
- }
}
for (cur_match = 0; cur_match < match_cnt; cur_match++) {
struct possible_tag *t = &all_matches[cur_match];
@@ -470,9 +473,8 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst)
fprintf(stderr, _("traversed %lu commits\n"), seen_commits);
if (gave_up_on) {
fprintf(stderr,
- _("more than %i tags found; listed %i most recent\n"
- "gave up search at %s\n"),
- max_candidates, max_candidates,
+ _("found %i tags; gave up search at %s\n"),
+ max_candidates,
oid_to_hex(&gave_up_on->object.oid));
}
}