diff options
| author | Tamir Duberstein <tamird@gmail.com> | 2026-06-12 17:49:13 -0400 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-06-12 15:56:44 -0700 |
| commit | ca96eeee79bc231f8096d9e9d0b501e0495e2db7 (patch) | |
| tree | 81fd102d1566bbd657df4aa2a407a05e3014cb9b /t/t4013/diff.diff_initial..side | |
| parent | 5bd39784cda151203aa6d97e24c21bf7fddc11de (diff) | |
ref-filter: memoize --contains with generations
git branch and git for-each-ref run a separate reachability walk for
each ref considered by --contains and --no-contains. Refs with shared
history therefore traverse the same commits repeatedly.
git tag instead uses a depth-first walk that caches results across
refs. That walk can perform poorly without generation numbers: a
negative check may walk to the root instead of stopping at a nearby
divergence. Generation numbers let it stop below the oldest target.
Use the memoized walk for all ref-filter callers when generation
numbers are available. Keep git tag on its existing path without
generations. Caching still helps when many tags share deep history:
ffc4b8012d (tag: speed up --contains calculation, 2011-06-11) reduced
git tag --contains HEAD~200 in linux-2.6 from 15.417 to 5.329 seconds.
The new shared-history perf test improves from 0.72 to 0.03 seconds. In
a repository with 62,174 remote-tracking refs, running:
git branch -r --contains c78ae85f3ce7e
improves from 104.365 seconds to 468 milliseconds.
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4013/diff.diff_initial..side')
0 files changed, 0 insertions, 0 deletions
