summaryrefslogtreecommitdiff
path: root/t/t5533-push-cas.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t5533-push-cas.sh')
-rwxr-xr-xt/t5533-push-cas.sh145
1 files changed, 74 insertions, 71 deletions
diff --git a/t/t5533-push-cas.sh b/t/t5533-push-cas.sh
index 7813e84..cba26a8 100755
--- a/t/t5533-push-cas.sh
+++ b/t/t5533-push-cas.sh
@@ -2,6 +2,9 @@
test_description='compare & swap push force/delete safety'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
. ./test-lib.sh
setup_srcdst_basic () {
@@ -29,22 +32,22 @@ setup_src_dup_dst () {
(
cd dup &&
git fetch &&
- git merge origin/master &&
- git switch -c branch master~2 &&
+ git merge origin/main &&
+ git switch -c branch main~2 &&
test_commit D &&
test_commit E &&
git push origin --all
) &&
(
cd src &&
- git switch master &&
+ git switch main &&
git fetch --all &&
git branch branch --track origin/branch &&
- git rebase origin/master
+ git rebase origin/main
) &&
(
cd dup &&
- git switch master &&
+ git switch main &&
test_commit F &&
test_commit G &&
git switch branch &&
@@ -65,11 +68,11 @@ test_expect_success 'push to update (protected)' '
(
cd dst &&
test_commit D &&
- test_must_fail git push --force-with-lease=master:master origin master 2>err &&
+ test_must_fail git push --force-with-lease=main:main origin main 2>err &&
grep "stale info" err
) &&
- git ls-remote . refs/heads/master >expect &&
- git ls-remote src refs/heads/master >actual &&
+ git ls-remote . refs/heads/main >expect &&
+ git ls-remote src refs/heads/main >actual &&
test_cmp expect actual
'
@@ -78,11 +81,11 @@ test_expect_success 'push to update (protected, forced)' '
(
cd dst &&
test_commit D &&
- git push --force --force-with-lease=master:master origin master 2>err &&
+ git push --force --force-with-lease=main:main origin main 2>err &&
grep "forced update" err
) &&
- git ls-remote dst refs/heads/master >expect &&
- git ls-remote src refs/heads/master >actual &&
+ git ls-remote dst refs/heads/main >expect &&
+ git ls-remote src refs/heads/main >actual &&
test_cmp expect actual
'
@@ -90,20 +93,20 @@ test_expect_success 'push to update (protected, tracking)' '
setup_srcdst_basic &&
(
cd src &&
- git checkout master &&
+ git checkout main &&
test_commit D &&
git checkout HEAD^0
) &&
- git ls-remote src refs/heads/master >expect &&
+ git ls-remote src refs/heads/main >expect &&
(
cd dst &&
test_commit E &&
- git ls-remote . refs/remotes/origin/master >expect &&
- test_must_fail git push --force-with-lease=master origin master &&
- git ls-remote . refs/remotes/origin/master >actual &&
+ 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 &&
test_cmp expect actual
) &&
- git ls-remote src refs/heads/master >actual &&
+ git ls-remote src refs/heads/main >actual &&
test_cmp expect actual
'
@@ -111,18 +114,18 @@ test_expect_success 'push to update (protected, tracking, forced)' '
setup_srcdst_basic &&
(
cd src &&
- git checkout master &&
+ git checkout main &&
test_commit D &&
git checkout HEAD^0
) &&
(
cd dst &&
test_commit E &&
- git ls-remote . refs/remotes/origin/master >expect &&
- git push --force --force-with-lease=master origin master
+ git ls-remote . refs/remotes/origin/main >expect &&
+ git push --force --force-with-lease=main origin main
) &&
- git ls-remote dst refs/heads/master >expect &&
- git ls-remote src refs/heads/master >actual &&
+ git ls-remote dst refs/heads/main >expect &&
+ git ls-remote src refs/heads/main >actual &&
test_cmp expect actual
'
@@ -131,10 +134,10 @@ test_expect_success 'push to update (allowed)' '
(
cd dst &&
test_commit D &&
- git push --force-with-lease=master:master^ origin master
+ git push --force-with-lease=main:main^ origin main
) &&
- git ls-remote dst refs/heads/master >expect &&
- git ls-remote src refs/heads/master >actual &&
+ git ls-remote dst refs/heads/main >expect &&
+ git ls-remote src refs/heads/main >actual &&
test_cmp expect actual
'
@@ -143,11 +146,11 @@ test_expect_success 'push to update (allowed, tracking)' '
(
cd dst &&
test_commit D &&
- git push --force-with-lease=master origin master 2>err &&
+ git push --force-with-lease=main origin main 2>err &&
! grep "forced update" err
) &&
- git ls-remote dst refs/heads/master >expect &&
- git ls-remote src refs/heads/master >actual &&
+ git ls-remote dst refs/heads/main >expect &&
+ git ls-remote src refs/heads/main >actual &&
test_cmp expect actual
'
@@ -157,22 +160,22 @@ test_expect_success 'push to update (allowed even though no-ff)' '
cd dst &&
git reset --hard HEAD^ &&
test_commit D &&
- git push --force-with-lease=master origin master 2>err &&
+ git push --force-with-lease=main origin main 2>err &&
grep "forced update" err
) &&
- git ls-remote dst refs/heads/master >expect &&
- git ls-remote src refs/heads/master >actual &&
+ git ls-remote dst refs/heads/main >expect &&
+ git ls-remote src refs/heads/main >actual &&
test_cmp expect actual
'
test_expect_success 'push to delete (protected)' '
setup_srcdst_basic &&
- git ls-remote src refs/heads/master >expect &&
+ git ls-remote src refs/heads/main >expect &&
(
cd dst &&
- test_must_fail git push --force-with-lease=master:master^ origin :master
+ test_must_fail git push --force-with-lease=main:main^ origin :main
) &&
- git ls-remote src refs/heads/master >actual &&
+ git ls-remote src refs/heads/main >actual &&
test_cmp expect actual
'
@@ -180,9 +183,9 @@ test_expect_success 'push to delete (protected, forced)' '
setup_srcdst_basic &&
(
cd dst &&
- git push --force --force-with-lease=master:master^ origin :master
+ git push --force --force-with-lease=main:main^ origin :main
) &&
- git ls-remote src refs/heads/master >actual &&
+ git ls-remote src refs/heads/main >actual &&
test_must_be_empty actual
'
@@ -190,10 +193,10 @@ test_expect_success 'push to delete (allowed)' '
setup_srcdst_basic &&
(
cd dst &&
- git push --force-with-lease=master origin :master 2>err &&
+ git push --force-with-lease=main origin :main 2>err &&
grep deleted err
) &&
- git ls-remote src refs/heads/master >actual &&
+ git ls-remote src refs/heads/main >actual &&
test_must_be_empty actual
'
@@ -201,12 +204,12 @@ test_expect_success 'cover everything with default force-with-lease (protected)'
setup_srcdst_basic &&
(
cd src &&
- git branch naster master^
+ git branch nain main^
) &&
git ls-remote src refs/heads/\* >expect &&
(
cd dst &&
- test_must_fail git push --force-with-lease origin master master:naster
+ test_must_fail git push --force-with-lease origin main main:nain
) &&
git ls-remote src refs/heads/\* >actual &&
test_cmp expect actual
@@ -216,16 +219,16 @@ test_expect_success 'cover everything with default force-with-lease (allowed)' '
setup_srcdst_basic &&
(
cd src &&
- git branch naster master^
+ git branch nain main^
) &&
(
cd dst &&
git fetch &&
- git push --force-with-lease origin master master:naster
+ git push --force-with-lease origin main main:nain
) &&
- git ls-remote dst refs/heads/master |
- sed -e "s/master/naster/" >expect &&
- git ls-remote src refs/heads/naster >actual &&
+ git ls-remote dst refs/heads/main |
+ sed -e "s/main/nain/" >expect &&
+ git ls-remote src refs/heads/nain >actual &&
test_cmp expect actual
'
@@ -233,7 +236,7 @@ test_expect_success 'new branch covered by force-with-lease' '
setup_srcdst_basic &&
(
cd dst &&
- git branch branch master &&
+ git branch branch main &&
git push --force-with-lease=branch origin branch
) &&
git ls-remote dst refs/heads/branch >expect &&
@@ -245,7 +248,7 @@ test_expect_success 'new branch covered by force-with-lease (explicit)' '
setup_srcdst_basic &&
(
cd dst &&
- git branch branch master &&
+ git branch branch main &&
git push --force-with-lease=branch: origin branch
) &&
git ls-remote dst refs/heads/branch >expect &&
@@ -257,12 +260,12 @@ test_expect_success 'new branch already exists' '
setup_srcdst_basic &&
(
cd src &&
- git checkout -b branch master &&
+ git checkout -b branch main &&
test_commit F
) &&
(
cd dst &&
- git branch branch master &&
+ git branch branch main &&
test_must_fail git push --force-with-lease=branch: origin branch
)
'
@@ -277,7 +280,7 @@ test_expect_success 'background updates of REMOTE can be mitigated with a non-up
cd dst &&
test_commit G &&
git remote add origin-push ../src.bare &&
- git push origin-push master:master
+ git push origin-push main:main
) &&
git clone --no-local src.bare dst2 &&
test_when_finished "rm -rf dst2" &&
@@ -299,58 +302,58 @@ test_expect_success 'background updates of REMOTE can be mitigated with a non-up
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" &&
- git ls-remote dst refs/heads/master >expect.master &&
+ git ls-remote dst refs/heads/main >expect.main &&
git ls-remote dst refs/heads/branch >expect.branch &&
(
cd src &&
git switch branch &&
test_commit I &&
- git switch master &&
+ git switch main &&
test_commit J &&
git fetch --all &&
test_must_fail git push --force-with-lease --force-if-includes --all
) &&
- git ls-remote dst refs/heads/master >actual.master &&
+ git ls-remote dst refs/heads/main >actual.main &&
git ls-remote dst refs/heads/branch >actual.branch &&
- test_cmp expect.master actual.master &&
+ test_cmp expect.main actual.main &&
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" &&
- git ls-remote dst refs/heads/master >expect.master &&
+ git ls-remote dst refs/heads/main >expect.main &&
(
cd src &&
git switch branch &&
test_commit I &&
- git switch master &&
+ git switch main &&
test_commit J &&
git fetch --all &&
git config --local push.useForceIfIncludes true &&
- test_must_fail git push --force-with-lease=master origin master
+ test_must_fail git push --force-with-lease=main origin main
) &&
- git ls-remote dst refs/heads/master >actual.master &&
- test_cmp expect.master actual.master
+ git ls-remote dst refs/heads/main >actual.main &&
+ test_cmp expect.main actual.main
'
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" &&
- git ls-remote dst refs/heads/master >expect.master &&
+ git ls-remote dst refs/heads/main >expect.main &&
(
cd src &&
git switch branch &&
test_commit I &&
- git switch master &&
+ git switch main &&
test_commit J &&
- remote_head="$(git rev-parse refs/remotes/origin/master)" &&
+ remote_head="$(git rev-parse refs/remotes/origin/main)" &&
git fetch --all &&
- test_must_fail git push --force-if-includes --force-with-lease="master:$remote_head" 2>err &&
+ test_must_fail git push --force-if-includes --force-with-lease="main:$remote_head" 2>err &&
grep "stale info" err
) &&
- git ls-remote dst refs/heads/master >actual.master &&
- test_cmp expect.master actual.master
+ git ls-remote dst refs/heads/main >actual.main &&
+ test_cmp expect.main actual.main
'
test_expect_success '"--force-if-includes" should allow forced update after a rebase ("pull --rebase")' '
@@ -360,10 +363,10 @@ test_expect_success '"--force-if-includes" should allow forced update after a re
cd src &&
git switch branch &&
test_commit I &&
- git switch master &&
+ git switch main &&
test_commit J &&
- git pull --rebase origin master &&
- git push --force-if-includes --force-with-lease="master"
+ git pull --rebase origin main &&
+ git push --force-if-includes --force-with-lease="main"
)
'
@@ -374,11 +377,11 @@ test_expect_success '"--force-if-includes" should allow forced update after a re
cd src &&
git switch branch &&
test_commit I &&
- git switch master &&
+ git switch main &&
test_commit J &&
- git pull --rebase origin master &&
+ git pull --rebase origin main &&
git rebase --onto HEAD~4 HEAD~1 &&
- git push --force-if-includes --force-with-lease="master"
+ git push --force-if-includes --force-with-lease="main"
)
'