2013-07-10 03:09:28 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='compare & swap push force/delete safety'
|
|
|
|
|
2020-11-19 07:44:33 +08:00
|
|
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
tests: mark tests relying on the current default for `init.defaultBranch`
In addition to the manual adjustment to let the `linux-gcc` CI job run
the test suite with `master` and then with `main`, this patch makes sure
that GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME is set in all test scripts
that currently rely on the initial branch name being `master by default.
To determine which test scripts to mark up, the first step was to
force-set the default branch name to `master` in
- all test scripts that contain the keyword `master`,
- t4211, which expects `t/t4211/history.export` with a hard-coded ref to
initialize the default branch,
- t5560 because it sources `t/t556x_common` which uses `master`,
- t8002 and t8012 because both source `t/annotate-tests.sh` which also
uses `master`)
This trick was performed by this command:
$ sed -i '/^ *\. \.\/\(test-lib\|lib-\(bash\|cvs\|git-svn\)\|gitweb-lib\)\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' $(git grep -l master t/t[0-9]*.sh) \
t/t4211*.sh t/t5560*.sh t/t8002*.sh t/t8012*.sh
After that, careful, manual inspection revealed that some of the test
scripts containing the needle `master` do not actually rely on a
specific default branch name: either they mention `master` only in a
comment, or they initialize that branch specificially, or they do not
actually refer to the current default branch. Therefore, the
aforementioned modification was undone in those test scripts thusly:
$ git checkout HEAD -- \
t/t0027-auto-crlf.sh t/t0060-path-utils.sh \
t/t1011-read-tree-sparse-checkout.sh \
t/t1305-config-include.sh t/t1309-early-config.sh \
t/t1402-check-ref-format.sh t/t1450-fsck.sh \
t/t2024-checkout-dwim.sh \
t/t2106-update-index-assume-unchanged.sh \
t/t3040-subprojects-basic.sh t/t3301-notes.sh \
t/t3308-notes-merge.sh t/t3423-rebase-reword.sh \
t/t3436-rebase-more-options.sh \
t/t4015-diff-whitespace.sh t/t4257-am-interactive.sh \
t/t5323-pack-redundant.sh t/t5401-update-hooks.sh \
t/t5511-refspec.sh t/t5526-fetch-submodules.sh \
t/t5529-push-errors.sh t/t5530-upload-pack-error.sh \
t/t5548-push-porcelain.sh \
t/t5552-skipping-fetch-negotiator.sh \
t/t5572-pull-submodule.sh t/t5608-clone-2gb.sh \
t/t5614-clone-submodules-shallow.sh \
t/t7508-status.sh t/t7606-merge-custom.sh \
t/t9302-fast-import-unpack-limit.sh
We excluded one set of test scripts in these commands, though: the range
of `git p4` tests. The reason? `git p4` stores the (foreign) remote
branch in the branch called `p4/master`, which is obviously not the
default branch. Manual analysis revealed that only five of these tests
actually require a specific default branch name to pass; They were
modified thusly:
$ sed -i '/^ *\. \.\/lib-git-p4\.sh$/i\
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master\
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\
' t/t980[0167]*.sh t/t9811*.sh
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-19 07:44:19 +08:00
|
|
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
|
|
|
|
2013-07-10 03:09:28 +08:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
setup_srcdst_basic () {
|
|
|
|
rm -fr src dst &&
|
|
|
|
git clone --no-local . src &&
|
|
|
|
git clone --no-local src dst &&
|
|
|
|
(
|
|
|
|
cd src && git checkout HEAD^0
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-10-03 20:10:46 +08:00
|
|
|
# For tests with "--force-if-includes".
|
|
|
|
setup_src_dup_dst () {
|
|
|
|
rm -fr src dup dst &&
|
|
|
|
git init --bare dst &&
|
|
|
|
git clone --no-local dst src &&
|
|
|
|
git clone --no-local dst dup
|
|
|
|
(
|
|
|
|
cd src &&
|
|
|
|
test_commit A &&
|
|
|
|
test_commit B &&
|
|
|
|
test_commit C &&
|
|
|
|
git push origin
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd dup &&
|
|
|
|
git fetch &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git merge origin/main &&
|
|
|
|
git switch -c branch main~2 &&
|
2020-10-03 20:10:46 +08:00
|
|
|
test_commit D &&
|
|
|
|
test_commit E &&
|
|
|
|
git push origin --all
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd src &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git switch main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
git fetch --all &&
|
|
|
|
git branch branch --track origin/branch &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git rebase origin/main
|
2020-10-03 20:10:46 +08:00
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd dup &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git switch main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
test_commit F &&
|
|
|
|
test_commit G &&
|
|
|
|
git switch branch &&
|
|
|
|
test_commit H &&
|
|
|
|
git push origin --all
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2013-07-10 03:09:28 +08:00
|
|
|
test_expect_success setup '
|
2015-03-20 18:12:37 +08:00
|
|
|
# create template repository
|
2013-07-10 03:09:28 +08:00
|
|
|
test_commit A &&
|
|
|
|
test_commit B &&
|
|
|
|
test_commit C
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push to update (protected)' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
|
|
|
test_commit D &&
|
2020-11-19 07:44:33 +08:00
|
|
|
test_must_fail git push --force-with-lease=main:main origin main 2>err &&
|
2016-01-30 07:18:42 +08:00
|
|
|
grep "stale info" err
|
2013-07-10 03:09:28 +08:00
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote . refs/heads/main >expect &&
|
|
|
|
git ls-remote src refs/heads/main >actual &&
|
2013-07-10 03:09:28 +08:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push to update (protected, forced)' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
|
|
|
test_commit D &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git push --force --force-with-lease=main:main origin main 2>err &&
|
2016-01-30 07:18:42 +08:00
|
|
|
grep "forced update" err
|
2013-07-10 03:09:28 +08:00
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote dst refs/heads/main >expect &&
|
|
|
|
git ls-remote src refs/heads/main >actual &&
|
2013-07-10 03:09:28 +08:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push to update (protected, tracking)' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd src &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git checkout main &&
|
2013-07-10 03:09:28 +08:00
|
|
|
test_commit D &&
|
|
|
|
git checkout HEAD^0
|
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote src refs/heads/main >expect &&
|
2013-07-10 03:09:28 +08:00
|
|
|
(
|
|
|
|
cd dst &&
|
|
|
|
test_commit E &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote . refs/remotes/origin/main >expect &&
|
|
|
|
test_must_fail git push --force-with-lease=main origin main &&
|
|
|
|
git ls-remote . refs/remotes/origin/main >actual &&
|
2013-07-10 03:09:28 +08:00
|
|
|
test_cmp expect actual
|
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote src refs/heads/main >actual &&
|
2013-07-10 03:09:28 +08:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push to update (protected, tracking, forced)' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd src &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git checkout main &&
|
2013-07-10 03:09:28 +08:00
|
|
|
test_commit D &&
|
|
|
|
git checkout HEAD^0
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
|
|
|
test_commit E &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote . refs/remotes/origin/main >expect &&
|
|
|
|
git push --force --force-with-lease=main origin main
|
2013-07-10 03:09:28 +08:00
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote dst refs/heads/main >expect &&
|
|
|
|
git ls-remote src refs/heads/main >actual &&
|
2013-07-10 03:09:28 +08:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push to update (allowed)' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
|
|
|
test_commit D &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git push --force-with-lease=main:main^ origin main
|
2013-07-10 03:09:28 +08:00
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote dst refs/heads/main >expect &&
|
|
|
|
git ls-remote src refs/heads/main >actual &&
|
2013-07-10 03:09:28 +08:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push to update (allowed, tracking)' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
|
|
|
test_commit D &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git push --force-with-lease=main origin main 2>err &&
|
2016-01-30 07:18:42 +08:00
|
|
|
! grep "forced update" err
|
2013-07-10 03:09:28 +08:00
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote dst refs/heads/main >expect &&
|
|
|
|
git ls-remote src refs/heads/main >actual &&
|
2013-07-10 03:09:28 +08:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push to update (allowed even though no-ff)' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
|
|
|
git reset --hard HEAD^ &&
|
|
|
|
test_commit D &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git push --force-with-lease=main origin main 2>err &&
|
2016-01-30 07:18:42 +08:00
|
|
|
grep "forced update" err
|
2013-07-10 03:09:28 +08:00
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote dst refs/heads/main >expect &&
|
|
|
|
git ls-remote src refs/heads/main >actual &&
|
2013-07-10 03:09:28 +08:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push to delete (protected)' '
|
|
|
|
setup_srcdst_basic &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote src refs/heads/main >expect &&
|
2013-07-10 03:09:28 +08:00
|
|
|
(
|
|
|
|
cd dst &&
|
2020-11-19 07:44:33 +08:00
|
|
|
test_must_fail git push --force-with-lease=main:main^ origin :main
|
2013-07-10 03:09:28 +08:00
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote src refs/heads/main >actual &&
|
2013-07-10 03:09:28 +08:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push to delete (protected, forced)' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git push --force --force-with-lease=main:main^ origin :main
|
2013-07-10 03:09:28 +08:00
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote src refs/heads/main >actual &&
|
2018-07-28 01:48:11 +08:00
|
|
|
test_must_be_empty actual
|
2013-07-10 03:09:28 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'push to delete (allowed)' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git push --force-with-lease=main origin :main 2>err &&
|
2016-01-30 07:18:42 +08:00
|
|
|
grep deleted err
|
2013-07-10 03:09:28 +08:00
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote src refs/heads/main >actual &&
|
2018-07-28 01:48:11 +08:00
|
|
|
test_must_be_empty actual
|
2013-07-10 03:09:28 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'cover everything with default force-with-lease (protected)' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd src &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git branch nain main^
|
2015-03-20 18:07:15 +08:00
|
|
|
) &&
|
2013-07-10 03:09:28 +08:00
|
|
|
git ls-remote src refs/heads/\* >expect &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
2020-11-19 07:44:33 +08:00
|
|
|
test_must_fail git push --force-with-lease origin main main:nain
|
2013-07-10 03:09:28 +08:00
|
|
|
) &&
|
|
|
|
git ls-remote src refs/heads/\* >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'cover everything with default force-with-lease (allowed)' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd src &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git branch nain main^
|
2015-03-20 18:07:15 +08:00
|
|
|
) &&
|
2013-07-10 03:09:28 +08:00
|
|
|
(
|
|
|
|
cd dst &&
|
|
|
|
git fetch &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git push --force-with-lease origin main main:nain
|
2013-07-10 03:09:28 +08:00
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote dst refs/heads/main |
|
|
|
|
sed -e "s/main/nain/" >expect &&
|
|
|
|
git ls-remote src refs/heads/nain >actual &&
|
2013-07-10 03:09:28 +08:00
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2016-07-27 04:44:45 +08:00
|
|
|
test_expect_success 'new branch covered by force-with-lease' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git branch branch main &&
|
2016-07-27 04:44:45 +08:00
|
|
|
git push --force-with-lease=branch origin branch
|
|
|
|
) &&
|
|
|
|
git ls-remote dst refs/heads/branch >expect &&
|
|
|
|
git ls-remote src refs/heads/branch >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2016-07-27 04:44:44 +08:00
|
|
|
test_expect_success 'new branch covered by force-with-lease (explicit)' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git branch branch main &&
|
2016-07-27 04:44:44 +08:00
|
|
|
git push --force-with-lease=branch: origin branch
|
|
|
|
) &&
|
|
|
|
git ls-remote dst refs/heads/branch >expect &&
|
|
|
|
git ls-remote src refs/heads/branch >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'new branch already exists' '
|
|
|
|
setup_srcdst_basic &&
|
|
|
|
(
|
|
|
|
cd src &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git checkout -b branch main &&
|
2016-08-04 22:54:35 +08:00
|
|
|
test_commit F
|
2016-07-27 04:44:44 +08:00
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git branch branch main &&
|
2016-07-27 04:44:44 +08:00
|
|
|
test_must_fail git push --force-with-lease=branch: origin branch
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2017-04-19 17:22:03 +08:00
|
|
|
test_expect_success 'background updates of REMOTE can be mitigated with a non-updated REMOTE-push' '
|
|
|
|
rm -rf src dst &&
|
|
|
|
git init --bare src.bare &&
|
|
|
|
test_when_finished "rm -rf src.bare" &&
|
|
|
|
git clone --no-local src.bare dst &&
|
|
|
|
test_when_finished "rm -rf dst" &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
|
|
|
test_commit G &&
|
|
|
|
git remote add origin-push ../src.bare &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git push origin-push main:main
|
2017-04-19 17:22:03 +08:00
|
|
|
) &&
|
|
|
|
git clone --no-local src.bare dst2 &&
|
|
|
|
test_when_finished "rm -rf dst2" &&
|
|
|
|
(
|
|
|
|
cd dst2 &&
|
|
|
|
test_commit H &&
|
|
|
|
git push
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd dst &&
|
|
|
|
test_commit I &&
|
|
|
|
git fetch origin &&
|
|
|
|
test_must_fail git push --force-with-lease origin-push &&
|
|
|
|
git fetch origin-push &&
|
|
|
|
git push --force-with-lease origin-push
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2020-10-03 20:10:46 +08:00
|
|
|
test_expect_success 'background updates to remote can be mitigated with "--force-if-includes"' '
|
|
|
|
setup_src_dup_dst &&
|
|
|
|
test_when_finished "rm -fr dst src dup" &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote dst refs/heads/main >expect.main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
git ls-remote dst refs/heads/branch >expect.branch &&
|
|
|
|
(
|
|
|
|
cd src &&
|
|
|
|
git switch branch &&
|
|
|
|
test_commit I &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git switch main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
test_commit J &&
|
|
|
|
git fetch --all &&
|
|
|
|
test_must_fail git push --force-with-lease --force-if-includes --all
|
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote dst refs/heads/main >actual.main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
git ls-remote dst refs/heads/branch >actual.branch &&
|
2020-11-19 07:44:33 +08:00
|
|
|
test_cmp expect.main actual.main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
test_cmp expect.branch actual.branch
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'background updates to remote can be mitigated with "push.useForceIfIncludes"' '
|
|
|
|
setup_src_dup_dst &&
|
|
|
|
test_when_finished "rm -fr dst src dup" &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote dst refs/heads/main >expect.main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
(
|
|
|
|
cd src &&
|
|
|
|
git switch branch &&
|
|
|
|
test_commit I &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git switch main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
test_commit J &&
|
|
|
|
git fetch --all &&
|
|
|
|
git config --local push.useForceIfIncludes true &&
|
2020-11-19 07:44:33 +08:00
|
|
|
test_must_fail git push --force-with-lease=main origin main
|
2020-10-03 20:10:46 +08:00
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote dst refs/heads/main >actual.main &&
|
|
|
|
test_cmp expect.main actual.main
|
2020-10-03 20:10:46 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"--force-if-includes" should be disabled for --force-with-lease="<refname>:<expect>"' '
|
|
|
|
setup_src_dup_dst &&
|
|
|
|
test_when_finished "rm -fr dst src dup" &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote dst refs/heads/main >expect.main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
(
|
|
|
|
cd src &&
|
|
|
|
git switch branch &&
|
|
|
|
test_commit I &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git switch main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
test_commit J &&
|
2020-11-19 07:44:33 +08:00
|
|
|
remote_head="$(git rev-parse refs/remotes/origin/main)" &&
|
2020-10-03 20:10:46 +08:00
|
|
|
git fetch --all &&
|
2020-11-19 07:44:33 +08:00
|
|
|
test_must_fail git push --force-if-includes --force-with-lease="main:$remote_head" 2>err &&
|
2020-10-03 20:10:46 +08:00
|
|
|
grep "stale info" err
|
|
|
|
) &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git ls-remote dst refs/heads/main >actual.main &&
|
|
|
|
test_cmp expect.main actual.main
|
2020-10-03 20:10:46 +08:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"--force-if-includes" should allow forced update after a rebase ("pull --rebase")' '
|
|
|
|
setup_src_dup_dst &&
|
|
|
|
test_when_finished "rm -fr dst src dup" &&
|
|
|
|
(
|
|
|
|
cd src &&
|
|
|
|
git switch branch &&
|
|
|
|
test_commit I &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git switch main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
test_commit J &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git pull --rebase origin main &&
|
|
|
|
git push --force-if-includes --force-with-lease="main"
|
2020-10-03 20:10:46 +08:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"--force-if-includes" should allow forced update after a rebase ("pull --rebase", local rebase)' '
|
|
|
|
setup_src_dup_dst &&
|
|
|
|
test_when_finished "rm -fr dst src dup" &&
|
|
|
|
(
|
|
|
|
cd src &&
|
|
|
|
git switch branch &&
|
|
|
|
test_commit I &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git switch main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
test_commit J &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git pull --rebase origin main &&
|
2020-10-03 20:10:46 +08:00
|
|
|
git rebase --onto HEAD~4 HEAD~1 &&
|
2020-11-19 07:44:33 +08:00
|
|
|
git push --force-if-includes --force-with-lease="main"
|
2020-10-03 20:10:46 +08:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"--force-if-includes" should allow deletes' '
|
|
|
|
setup_src_dup_dst &&
|
|
|
|
test_when_finished "rm -fr dst src dup" &&
|
|
|
|
(
|
|
|
|
cd src &&
|
|
|
|
git switch branch &&
|
|
|
|
git pull --rebase origin branch &&
|
|
|
|
git push --force-if-includes --force-with-lease="branch" origin :branch
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2013-07-10 03:09:28 +08:00
|
|
|
test_done
|