]> git.ipfire.org Git - thirdparty/git.git/commit
Revert "reflog expire: don't use lookup_commit_reference_gently()"
authorJunio C Hamano <gitster@pobox.com>
Tue, 16 Jul 2024 19:56:25 +0000 (12:56 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Jul 2024 21:15:35 +0000 (14:15 -0700)
commit5133ead5286546d65b038b9381ef8b1cd4663c0b
treec0d76e8fe39b57e96750ed36fa1c847a7abf7e0e
parent3c2a3fdc388747b9eaf4a4a4f2035c1c9ddb26d0
Revert "reflog expire: don't use lookup_commit_reference_gently()"

During Git 2.35 timeframe, daf1d828 (reflog expire: don't use
lookup_commit_reference_gently(), 2021-12-22) replaced a call to
lookup_commit_reference_gently() with a call to lookup_commit().

What it failed to consider was that our refs do not necessarily
point at commits (most notably, we have annotated and signed tags),
and more importantly that lookup_commit() does not dereference a tag
to return a commit; instead it returns NULL when a tag is given.

Since the commit returned is used as a starting point for the
reachability check, this ejected the commits that are reachable only
by an annotated tag out of the set of reachable commits, breaking
the computation to correctly implement the "--expire-unreachable"
option.  We also started giving an error message that the API
function expected to be fed a commit object.

This problem hasn't been reported or noticed for a long time,
probably because the "refs/tags/" hierarchy by default is not
covered by reflogs, as nobody usually moves tags.

Revert the change to correctly find the commit pointed at by the ref
to restore the previous behaviour, but do so only in a more modern
codebase, as we had significant code churn since then and it is not
grave enough to worry about for older maintenance tracks.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
reflog.c
t/t1410-reflog.sh