Skip to content

Commit 7f7d1ad

Browse files
committed
Merge branch 'ab/reflog-prep-fix'
Regression fix. * ab/reflog-prep-fix: reflog: don't be noisy on empty reflogs
2 parents d674bf5 + 57be9c6 commit 7f7d1ad

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

reflog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ void reflog_expiry_prepare(const char *refname,
334334
cb->unreachable_expire_kind = UE_HEAD;
335335
} else {
336336
commit = lookup_commit(the_repository, oid);
337+
if (commit && is_null_oid(&commit->object.oid))
338+
commit = NULL;
337339
cb->unreachable_expire_kind = commit ? UE_NORMAL : UE_ALWAYS;
338340
}
339341

t/t1410-reflog.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,4 +423,13 @@ test_expect_success 'expire with multiple worktrees' '
423423
)
424424
'
425425

426+
test_expect_success REFFILES 'empty reflog' '
427+
test_when_finished "rm -rf empty" &&
428+
git init empty &&
429+
test_commit -C empty A &&
430+
>empty/.git/logs/refs/heads/foo &&
431+
git -C empty reflog expire --all 2>err &&
432+
test_must_be_empty err
433+
'
434+
426435
test_done

0 commit comments

Comments
 (0)