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

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
This commit is contained in:
Junio C Hamano committed 2026-10-06 10:13:31 -07:00
commit c679abf7d2
2 files changed
+17 -1

No files matched your search

+1 -1
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;
+16
View File
@@ -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