diff --git a/remote.c b/remote.c index fe62068463..71170f36a9 100644 --- a/remote.c +++ b/remote.c @@ -2844,7 +2844,7 @@ static int check_and_collect_until(const char *refname UNUSED, */ static int is_reachable_in_reflog(const char *local, const struct ref *remote) { - timestamp_t date; + timestamp_t date = 0; struct commit *commit; struct commit **chunk; struct check_and_collect_until_cb_data cb; diff --git a/t/t5533-push-cas.sh b/t/t5533-push-cas.sh index 2e14aecaa2..e6e1360a42 100755 --- a/t/t5533-push-cas.sh +++ b/t/t5533-push-cas.sh @@ -396,4 +396,20 @@ test_expect_success '"--force-if-includes" should allow deletes' ' ) ' +test_expect_success '"--force-if-includes" should allow forced update when remote-tracking ref has no reflog' ' + setup_src_dup_dst && + test_when_finished "rm -fr dst src dup" && + ( + cd src && + git switch branch && + git pull --rebase origin branch && + # the bug needs a remote-tracking ref with no reflog, and + # the fetch above wrote one + git reflog expire --expire=all refs/remotes/origin/branch && + git reset --hard HEAD^ && + test_commit I && + git push --force-if-includes --force-with-lease="branch" + ) +' + test_done