Skip to content

Commit d3acb90

Browse files
committed
Merge branch 'as/push-force-if-includes-no-reflog' into next
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
2 parents 3b93956 + c84ed3a commit d3acb90

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎remote.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2844,7 +2844,7 @@ static int check_and_collect_until(const char *refname UNUSED,
28442844
*/
28452845
static int is_reachable_in_reflog(const char *local, const struct ref *remote)
28462846
{
2847-
timestamp_t date;
2847+
timestamp_t date = 0;
28482848
struct commit *commit;
28492849
struct commit **chunk;
28502850
struct check_and_collect_until_cb_data cb;

‎t/t5533-push-cas.sh‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,20 @@ test_expect_success '"--force-if-includes" should allow deletes' '
396396
)
397397
'
398398

399+
test_expect_success '"--force-if-includes" should allow forced update when remote-tracking ref has no reflog' '
400+
setup_src_dup_dst &&
401+
test_when_finished "rm -fr dst src dup" &&
402+
(
403+
cd src &&
404+
git switch branch &&
405+
git pull --rebase origin branch &&
406+
# the bug needs a remote-tracking ref with no reflog, and
407+
# the fetch above wrote one
408+
git reflog expire --expire=all refs/remotes/origin/branch &&
409+
git reset --hard HEAD^ &&
410+
test_commit I &&
411+
git push --force-if-includes --force-with-lease="branch"
412+
)
413+
'
414+
399415
test_done

0 commit comments

Comments
 (0)