Merge branch 'ab/reflog-prep-fix'

Regression fix.

* ab/reflog-prep-fix:
  reflog: don't be noisy on empty reflogs
This commit is contained in:
Junio C Hamano 2022-03-23 14:09:30 -07:00
Родитель d674bf5570 57be9c6dee
Коммит 7f7d1ad3e0
2 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -334,6 +334,8 @@ void reflog_expiry_prepare(const char *refname,
cb->unreachable_expire_kind = UE_HEAD; cb->unreachable_expire_kind = UE_HEAD;
} else { } else {
commit = lookup_commit(the_repository, oid); commit = lookup_commit(the_repository, oid);
if (commit && is_null_oid(&commit->object.oid))
commit = NULL;
cb->unreachable_expire_kind = commit ? UE_NORMAL : UE_ALWAYS; cb->unreachable_expire_kind = commit ? UE_NORMAL : UE_ALWAYS;
} }

Просмотреть файл

@ -423,4 +423,13 @@ test_expect_success 'expire with multiple worktrees' '
) )
' '
test_expect_success REFFILES 'empty reflog' '
test_when_finished "rm -rf empty" &&
git init empty &&
test_commit -C empty A &&
>empty/.git/logs/refs/heads/foo &&
git -C empty reflog expire --all 2>err &&
test_must_be_empty err
'
test_done test_done