Merge branch 'as/push-force-if-includes-no-reflog' into seen

The timestamp used for checking the reflog of a remote-tracking
branch during 'git push --force-if-includes' was left uninitialized
when the reflog was completely empty, which has been corrected.

* as/push-force-if-includes-no-reflog:
  push: fix --force-if-includes when remote-tracking ref has no reflog
Junio C Hamano 2026-09-21 10:04:23 -07:00
commit 29bd1302d2
2 changed files with 19 additions and 1 deletions

View File

@ -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;

View File

@ -396,4 +396,22 @@ 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' '
rm -fr dst src &&
test_when_finished "rm -fr dst src" &&
git init --bare dst &&
git push dst main main:branch &&
git clone --no-local dst src &&
(
cd src &&
# a clone leaves the remote-tracking refs without reflog
# entries with the files backend, but not with reftable
git reflog expire --all --expire=all &&
git switch -c branch --track origin/branch &&
git reset --hard HEAD^ &&
test_commit D &&
git push --force-if-includes --force-with-lease="branch"
)
'

test_done