1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-28 04:49:43 +01:00

Merge branch 'jc/reflog-expire-lookup-commit-fix' into maint-2.46

"git reflog expire" failed to honor annotated tags when computing
reachable commits.

* jc/reflog-expire-lookup-commit-fix:
  Revert "reflog expire: don't use lookup_commit_reference_gently()"
This commit is contained in:
Junio C Hamano 2024-08-26 11:10:21 -07:00
commit 710ef8a945
2 changed files with 10 additions and 1 deletions

View file

@ -332,7 +332,8 @@ void reflog_expiry_prepare(const char *refname,
if (!cb->cmd.expire_unreachable || is_head(refname)) {
cb->unreachable_expire_kind = UE_HEAD;
} else {
commit = lookup_commit(the_repository, oid);
commit = lookup_commit_reference_gently(the_repository,
oid, 1);
if (commit && is_null_oid(&commit->object.oid))
commit = NULL;
cb->unreachable_expire_kind = commit ? UE_NORMAL : UE_ALWAYS;

View file

@ -146,6 +146,14 @@ test_expect_success rewind '
test_line_count = 5 output
'
test_expect_success 'reflog expire should not barf on an annotated tag' '
test_when_finished "git tag -d v0.tag || :" &&
git -c core.logAllRefUpdates=always \
tag -a -m "tag name" v0.tag main &&
git reflog expire --dry-run refs/tags/v0.tag 2>err &&
test_grep ! "error: [Oo]bject .* not a commit" err
'
test_expect_success 'corrupt and check' '
corrupt $F &&