Skip to content

Commit 710ef8a

Browse files
committed
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()"
2 parents 7bba1bd + 5133ead commit 710ef8a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

reflog.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ void reflog_expiry_prepare(const char *refname,
332332
if (!cb->cmd.expire_unreachable || is_head(refname)) {
333333
cb->unreachable_expire_kind = UE_HEAD;
334334
} else {
335-
commit = lookup_commit(the_repository, oid);
335+
commit = lookup_commit_reference_gently(the_repository,
336+
oid, 1);
336337
if (commit && is_null_oid(&commit->object.oid))
337338
commit = NULL;
338339
cb->unreachable_expire_kind = commit ? UE_NORMAL : UE_ALWAYS;

t/t1410-reflog.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ test_expect_success rewind '
146146
test_line_count = 5 output
147147
'
148148

149+
test_expect_success 'reflog expire should not barf on an annotated tag' '
150+
test_when_finished "git tag -d v0.tag || :" &&
151+
git -c core.logAllRefUpdates=always \
152+
tag -a -m "tag name" v0.tag main &&
153+
git reflog expire --dry-run refs/tags/v0.tag 2>err &&
154+
test_grep ! "error: [Oo]bject .* not a commit" err
155+
'
156+
149157
test_expect_success 'corrupt and check' '
150158
151159
corrupt $F &&

0 commit comments

Comments
 (0)