Merge branch 'td/describe-tag-iteration' into jch

'git describe' has been taught to pass the 'refs/tags/' prefix down to
the ref iterator when '--all' is not requested, avoiding unnecessary
iteration over non-tag refs.

* td/describe-tag-iteration:
  describe: limit default ref iteration to tags
This commit is contained in:
Junio C Hamano
2026-06-13 09:22:02 -07:00
2 changed files with 15 additions and 0 deletions

View File

@@ -752,6 +752,9 @@ int cmd_describe(int argc,
return ret;
}
if (!all)
for_each_ref_opts.prefix = "refs/tags/";
hashmap_init(&names, commit_name_neq, NULL, 0);
refs_for_each_ref_ext(get_main_ref_store(the_repository),
get_name, NULL, &for_each_ref_opts);

View File

@@ -27,4 +27,16 @@ test_perf 'describe HEAD with one tag' '
git describe --match=new HEAD
'
test_expect_success 'set up many unrelated refs' '
ref_count=10000 &&
git tag -m tip tip HEAD &&
test_seq -f "create refs/heads/describe-perf/%05d HEAD" $ref_count |
git update-ref --stdin &&
git pack-refs --all
'
test_perf 'describe exact tag with many unrelated refs' '
git describe --exact-match HEAD
'
test_done