diff options
author | Junio C Hamano <gitster@pobox.com> | 2024-08-26 20:10:21 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-08-26 20:10:21 +0200 |
commit | 710ef8a9458172646e830a82ba110ab2176cf669 (patch) | |
tree | 63c15ba5daa5decb9597201a8287828139f78759 | |
parent | Merge branch 'jr/ls-files-expand-literal-doc' into maint-2.46 (diff) | |
parent | Revert "reflog expire: don't use lookup_commit_reference_gently()" (diff) | |
download | git-710ef8a9458172646e830a82ba110ab2176cf669.tar.xz git-710ef8a9458172646e830a82ba110ab2176cf669.zip |
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()"
-rw-r--r-- | reflog.c | 3 | ||||
-rwxr-xr-x | t/t1410-reflog.sh | 8 |
2 files changed, 10 insertions, 1 deletions
@@ -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; diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index 5bf883f1e3..246a3f46ab 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -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 && |