Merge branch 'jc/reflog-expire-lookup-commit-fix'
"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:
3
reflog.c
3
reflog.c
@ -332,7 +332,8 @@ void reflog_expiry_prepare(const char *refname,
|
|||||||
if (!cb->cmd.expire_unreachable || is_head(refname)) {
|
if (!cb->cmd.expire_unreachable || is_head(refname)) {
|
||||||
cb->unreachable_expire_kind = UE_HEAD;
|
cb->unreachable_expire_kind = UE_HEAD;
|
||||||
} else {
|
} else {
|
||||||
commit = lookup_commit(the_repository, oid);
|
commit = lookup_commit_reference_gently(the_repository,
|
||||||
|
oid, 1);
|
||||||
if (commit && is_null_oid(&commit->object.oid))
|
if (commit && is_null_oid(&commit->object.oid))
|
||||||
commit = NULL;
|
commit = NULL;
|
||||||
cb->unreachable_expire_kind = commit ? UE_NORMAL : UE_ALWAYS;
|
cb->unreachable_expire_kind = commit ? UE_NORMAL : UE_ALWAYS;
|
||||||
|
@ -146,6 +146,14 @@ test_expect_success rewind '
|
|||||||
test_line_count = 5 output
|
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' '
|
test_expect_success 'corrupt and check' '
|
||||||
|
|
||||||
corrupt $F &&
|
corrupt $F &&
|
||||||
|
Reference in New Issue
Block a user