]> git.ipfire.org Git - thirdparty/git.git/commit
describe: limit default ref iteration to tags
authorTamir Duberstein <tamird@gmail.com>
Wed, 10 Jun 2026 18:50:01 +0000 (11:50 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Jun 2026 19:38:49 +0000 (12:38 -0700)
commit55088ac8a480d94ccf37bc53b6b2ddc7475b269b
treebb7be712dc97d52f4e77ed23bc88b7515daea2af
parent94f057755b7941b321fd11fec1b2e3ca5313a4e0
describe: limit default ref iteration to tags

Without --all, git describe ignores refs outside refs/tags/. Commit
8a5a1884e9 (Avoid accessing non-tag refs in git-describe unless --all is
requested, 2008-02-24) moved this check ahead of object lookup. That
avoided loading objects for irrelevant refs, but the backend still has
to yield every ref before get_name() can reject it.

Pass refs/tags/ to the iterator so the backend can avoid visiting those
refs in the first place.

The new perf test creates 10,000 unrelated packed refs. It measures:

    git describe --exact-match HEAD

The runtime drops from 0.03(0.01+0.01) to 0.02(0.00+0.00). In a
repository with 120,532 refs but only 330 tags, the same command went
from 171.7 ms to 9.9 ms.

Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/describe.c
t/perf/p6100-describe.sh