diff options
Diffstat (limited to 't/t5531-deep-submodule-push.sh')
-rwxr-xr-x | t/t5531-deep-submodule-push.sh | 191 |
1 files changed, 97 insertions, 94 deletions
diff --git a/t/t5531-deep-submodule-push.sh b/t/t5531-deep-submodule-push.sh index 4ad059e6be..d573ca496a 100755 --- a/t/t5531-deep-submodule-push.sh +++ b/t/t5531-deep-submodule-push.sh @@ -2,6 +2,9 @@ test_description='test push with submodules' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh test_expect_success setup ' @@ -30,7 +33,7 @@ test_expect_success setup ' test_expect_success 'push works with recorded gitlink' ' ( cd work && - git push ../pub.git master + git push ../pub.git main ) ' @@ -45,7 +48,7 @@ test_expect_success 'push if submodule has no remote' ' cd work && git add gar/bage && git commit -m "Second commit for gar/bage" && - git push --recurse-submodules=check ../pub.git master + git push --recurse-submodules=check ../pub.git main ) ' @@ -66,21 +69,21 @@ test_expect_success 'push fails if submodule commit not on remote' ' git commit -m "Third commit for gar/bage" && # the push should fail with --recurse-submodules=check # on the command line... - test_must_fail git push --recurse-submodules=check ../pub.git master && + test_must_fail git push --recurse-submodules=check ../pub.git main && # ...or if specified in the configuration.. - test_must_fail git -c push.recurseSubmodules=check push ../pub.git master + test_must_fail git -c push.recurseSubmodules=check push ../pub.git main ) ' test_expect_success 'push succeeds after commit was pushed to remote' ' ( cd work/gar/bage && - git push origin master + git push origin main ) && ( cd work && - git push --recurse-submodules=check ../pub.git master + git push --recurse-submodules=check ../pub.git main ) ' @@ -95,13 +98,13 @@ test_expect_success 'push succeeds if submodule commit not on remote but using o cd work && git add gar/bage && git commit -m "Recurse on-demand on command line for gar/bage" && - git push --recurse-submodules=on-demand ../pub.git master && + git push --recurse-submodules=on-demand ../pub.git main && # Check that the supermodule commit got there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # Check that the submodule commit got there too cd gar/bage && - git diff --quiet origin/master master + git diff --quiet origin/main main ) ' @@ -116,13 +119,13 @@ test_expect_success 'push succeeds if submodule commit not on remote but using o cd work && git add gar/bage && git commit -m "Recurse on-demand from config for gar/bage" && - git -c push.recurseSubmodules=on-demand push ../pub.git master && + git -c push.recurseSubmodules=on-demand push ../pub.git main && # Check that the supermodule commit got there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # Check that the submodule commit got there too cd gar/bage && - git diff --quiet origin/master master + git diff --quiet origin/main main ) ' @@ -137,13 +140,13 @@ test_expect_success 'push succeeds if submodule commit not on remote but using a cd work && git add gar/bage && git commit -m "Recurse submodule.recurse from config for gar/bage" && - git -c submodule.recurse push ../pub.git master && + git -c submodule.recurse push ../pub.git main && # Check that the supermodule commit got there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # Check that the submodule commit got there too cd gar/bage && - git diff --quiet origin/master master + git diff --quiet origin/main main ) ' @@ -161,34 +164,34 @@ test_expect_success 'push recurse-submodules on command line overrides config' ' # Ensure that we can override on-demand in the config # to just check submodules - test_must_fail git -c push.recurseSubmodules=on-demand push --recurse-submodules=check ../pub.git master && + test_must_fail git -c push.recurseSubmodules=on-demand push --recurse-submodules=check ../pub.git main && # Check that the supermodule commit did not get there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master^ && + git diff --quiet FETCH_HEAD main^ && # Check that the submodule commit did not get there - (cd gar/bage && git diff --quiet origin/master master^) && + (cd gar/bage && git diff --quiet origin/main main^) && # Ensure that we can override check in the config to # disable submodule recursion entirely - (cd gar/bage && git diff --quiet origin/master master^) && - git -c push.recurseSubmodules=on-demand push --recurse-submodules=no ../pub.git master && + (cd gar/bage && git diff --quiet origin/main main^) && + git -c push.recurseSubmodules=on-demand push --recurse-submodules=no ../pub.git main && git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && - (cd gar/bage && git diff --quiet origin/master master^) && + git diff --quiet FETCH_HEAD main && + (cd gar/bage && git diff --quiet origin/main main^) && # Ensure that we can override check in the config to # disable submodule recursion entirely (alternative form) - git -c push.recurseSubmodules=on-demand push --no-recurse-submodules ../pub.git master && + git -c push.recurseSubmodules=on-demand push --no-recurse-submodules ../pub.git main && git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && - (cd gar/bage && git diff --quiet origin/master master^) && + git diff --quiet FETCH_HEAD main && + (cd gar/bage && git diff --quiet origin/main main^) && # Ensure that we can override check in the config to # push the submodule too - git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git master && + git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git main && git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && - (cd gar/bage && git diff --quiet origin/master master) + git diff --quiet FETCH_HEAD main && + (cd gar/bage && git diff --quiet origin/main main) ) ' @@ -205,31 +208,31 @@ test_expect_success 'push recurse-submodules last one wins on command line' ' git commit -m "Recurse on command-line overriding earlier command-line for gar/bage" && # should result in "check" - test_must_fail git push --recurse-submodules=on-demand --recurse-submodules=check ../pub.git master && + test_must_fail git push --recurse-submodules=on-demand --recurse-submodules=check ../pub.git main && # Check that the supermodule commit did not get there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master^ && + git diff --quiet FETCH_HEAD main^ && # Check that the submodule commit did not get there - (cd gar/bage && git diff --quiet origin/master master^) && + (cd gar/bage && git diff --quiet origin/main main^) && # should result in "no" - git push --recurse-submodules=on-demand --recurse-submodules=no ../pub.git master && + git push --recurse-submodules=on-demand --recurse-submodules=no ../pub.git main && # Check that the supermodule commit did get there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # Check that the submodule commit did not get there - (cd gar/bage && git diff --quiet origin/master master^) && + (cd gar/bage && git diff --quiet origin/main main^) && # should result in "no" - git push --recurse-submodules=on-demand --no-recurse-submodules ../pub.git master && + git push --recurse-submodules=on-demand --no-recurse-submodules ../pub.git main && # Check that the submodule commit did not get there - (cd gar/bage && git diff --quiet origin/master master^) && + (cd gar/bage && git diff --quiet origin/main main^) && # But the options in the other order should push the submodule - git push --recurse-submodules=check --recurse-submodules=on-demand ../pub.git master && + git push --recurse-submodules=check --recurse-submodules=on-demand ../pub.git main && # Check that the submodule commit did get there git fetch ../pub.git && - (cd gar/bage && git diff --quiet origin/master master) + (cd gar/bage && git diff --quiet origin/main main) ) ' @@ -244,13 +247,13 @@ test_expect_success 'push succeeds if submodule commit not on remote using on-de cd work && git add gar/bage && git commit -m "Recurse on-demand on command-line overriding config for gar/bage" && - git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git master && + git -c push.recurseSubmodules=check push --recurse-submodules=on-demand ../pub.git main && # Check that the supermodule commit got there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # Check that the submodule commit got there cd gar/bage && - git diff --quiet origin/master master + git diff --quiet origin/main main ) ' @@ -265,14 +268,14 @@ test_expect_success 'push succeeds if submodule commit disabling recursion from cd work && git add gar/bage && git commit -m "Recurse disable on command-line overriding config for gar/bage" && - git -c push.recurseSubmodules=check push --recurse-submodules=no ../pub.git master && + git -c push.recurseSubmodules=check push --recurse-submodules=no ../pub.git main && # Check that the supermodule commit got there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # But that the submodule commit did not - ( cd gar/bage && git diff --quiet origin/master master^ ) && + ( cd gar/bage && git diff --quiet origin/main main^ ) && # Now push it to avoid confusing future tests - git push --recurse-submodules=on-demand ../pub.git master + git push --recurse-submodules=on-demand ../pub.git main ) ' @@ -287,14 +290,14 @@ test_expect_success 'push succeeds if submodule commit disabling recursion from cd work && git add gar/bage && git commit -m "Recurse disable on command-line alternative overriding config for gar/bage" && - git -c push.recurseSubmodules=check push --no-recurse-submodules ../pub.git master && + git -c push.recurseSubmodules=check push --no-recurse-submodules ../pub.git main && # Check that the supermodule commit got there git fetch ../pub.git && - git diff --quiet FETCH_HEAD master && + git diff --quiet FETCH_HEAD main && # But that the submodule commit did not - ( cd gar/bage && git diff --quiet origin/master master^ ) && + ( cd gar/bage && git diff --quiet origin/main main^ ) && # Now push it to avoid confusing future tests - git push --recurse-submodules=on-demand ../pub.git master + git push --recurse-submodules=on-demand ../pub.git main ) ' @@ -304,7 +307,7 @@ test_expect_success 'submodule entry pointing at a tag is error' ' git -C work update-index --cacheinfo 160000 "$tag" gar/bage && git -C work commit -m "bad commit" && test_when_finished "git -C work reset --hard HEAD^" && - test_must_fail git -C work push --recurse-submodules=on-demand ../pub.git master 2>err && + test_must_fail git -C work push --recurse-submodules=on-demand ../pub.git main 2>err && test_i18ngrep "is a tag, not a commit" err ' @@ -319,9 +322,9 @@ test_expect_success 'push fails if recurse submodules option passed as yes' ' cd work && git add gar/bage && git commit -m "Recurse push fails if recurse submodules option passed as yes for gar/bage" && - test_must_fail git push --recurse-submodules=yes ../pub.git master && - test_must_fail git -c push.recurseSubmodules=yes push ../pub.git master && - git push --recurse-submodules=on-demand ../pub.git master + test_must_fail git push --recurse-submodules=yes ../pub.git main && + test_must_fail git -c push.recurseSubmodules=yes push ../pub.git main && + git push --recurse-submodules=on-demand ../pub.git main ) ' @@ -363,7 +366,7 @@ test_expect_success 'push succeeds if submodule has no remote and is on the firs ) && git add b && git commit -m "added submodule" && - git push --recurse-submodules=check origin master + git push --recurse-submodules=check origin main ) ' @@ -372,21 +375,21 @@ test_expect_success 'push unpushed submodules when not needed' ' cd work && ( cd gar/bage && - git checkout master && + git checkout main && >junk5 && git add junk5 && git commit -m "Fifth junk" && git push && - git rev-parse origin/master >../../../expected + git rev-parse origin/main >../../../expected ) && - git checkout master && + git checkout main && git add gar/bage && git commit -m "Fifth commit for gar/bage" && - git push --recurse-submodules=on-demand ../pub.git master + git push --recurse-submodules=on-demand ../pub.git main ) && ( cd submodule.git && - git rev-parse master >../actual + git rev-parse main >../actual ) && test_cmp expected actual ' @@ -394,7 +397,7 @@ test_expect_success 'push unpushed submodules when not needed' ' test_expect_success 'push unpushed submodules when not needed 2' ' ( cd submodule.git && - git rev-parse master >../expected + git rev-parse main >../expected ) && ( cd work && @@ -407,11 +410,11 @@ test_expect_success 'push unpushed submodules when not needed 2' ' >junk2 && git add junk2 && git commit -m "Second junk for work" && - git push --recurse-submodules=on-demand ../pub.git master + git push --recurse-submodules=on-demand ../pub.git main ) && ( cd submodule.git && - git rev-parse master >../actual + git rev-parse main >../actual ) && test_cmp expected actual ' @@ -421,20 +424,20 @@ test_expect_success 'push unpushed submodules recursively' ' cd work && ( cd gar/bage && - git checkout master && + git checkout main && > junk7 && git add junk7 && git commit -m "Seventh junk" && - git rev-parse master >../../../expected + git rev-parse main >../../../expected ) && - git checkout master && + git checkout main && git add gar/bage && git commit -m "Seventh commit for gar/bage" && - git push --recurse-submodules=on-demand ../pub.git master + git push --recurse-submodules=on-demand ../pub.git main ) && ( cd submodule.git && - git rev-parse master >../actual + git rev-parse main >../actual ) && test_cmp expected actual ' @@ -444,64 +447,64 @@ test_expect_success 'push unpushable submodule recursively fails' ' cd work && ( cd gar/bage && - git rev-parse origin/master >../../../expected && - git checkout master~0 && + git rev-parse origin/main >../../../expected && + git checkout main~0 && > junk8 && git add junk8 && git commit -m "Eighth junk" ) && git add gar/bage && git commit -m "Eighth commit for gar/bage" && - test_must_fail git push --recurse-submodules=on-demand ../pub.git master + test_must_fail git push --recurse-submodules=on-demand ../pub.git main ) && ( cd submodule.git && - git rev-parse master >../actual + git rev-parse main >../actual ) && - test_when_finished git -C work reset --hard master^ && + test_when_finished git -C work reset --hard main^ && test_cmp expected actual ' test_expect_success 'push --dry-run does not recursively update submodules' ' ( cd work/gar/bage && - git checkout master && - git rev-parse master >../../../expected_submodule && + git checkout main && + git rev-parse main >../../../expected_submodule && > junk9 && git add junk9 && git commit -m "Ninth junk" && # Go up to 'work' directory cd ../.. && - git checkout master && - git rev-parse master >../expected_pub && + git checkout main && + git rev-parse main >../expected_pub && git add gar/bage && git commit -m "Ninth commit for gar/bage" && - git push --dry-run --recurse-submodules=on-demand ../pub.git master + git push --dry-run --recurse-submodules=on-demand ../pub.git main ) && - git -C submodule.git rev-parse master >actual_submodule && - git -C pub.git rev-parse master >actual_pub && + git -C submodule.git rev-parse main >actual_submodule && + git -C pub.git rev-parse main >actual_pub && test_cmp expected_pub actual_pub && test_cmp expected_submodule actual_submodule ' test_expect_success 'push --dry-run does not recursively update submodules' ' - git -C work push --dry-run --recurse-submodules=only ../pub.git master && + git -C work push --dry-run --recurse-submodules=only ../pub.git main && - git -C submodule.git rev-parse master >actual_submodule && - git -C pub.git rev-parse master >actual_pub && + git -C submodule.git rev-parse main >actual_submodule && + git -C pub.git rev-parse main >actual_pub && test_cmp expected_pub actual_pub && test_cmp expected_submodule actual_submodule ' test_expect_success 'push only unpushed submodules recursively' ' - git -C work/gar/bage rev-parse master >expected_submodule && - git -C pub.git rev-parse master >expected_pub && + git -C work/gar/bage rev-parse main >expected_submodule && + git -C pub.git rev-parse main >expected_pub && - git -C work push --recurse-submodules=only ../pub.git master && + git -C work push --recurse-submodules=only ../pub.git main && - git -C submodule.git rev-parse master >actual_submodule && - git -C pub.git rev-parse master >actual_pub && + git -C submodule.git rev-parse main >actual_submodule && + git -C pub.git rev-parse main >actual_pub && test_cmp expected_submodule actual_submodule && test_cmp expected_pub actual_pub ' @@ -517,14 +520,14 @@ test_expect_success 'push propagating the remotes name to a submodule' ' git -C work commit -m "Tenth junk added to gar/bage" && # Fails when submodule does not have a matching remote - test_must_fail git -C work push --recurse-submodules=on-demand pub master && + test_must_fail git -C work push --recurse-submodules=on-demand pub main && # Succeeds when submodules has matching remote and refspec - git -C work push --recurse-submodules=on-demand origin master && + git -C work push --recurse-submodules=on-demand origin main && - git -C submodule.git rev-parse master >actual_submodule && - git -C pub.git rev-parse master >actual_pub && - git -C work/gar/bage rev-parse master >expected_submodule && - git -C work rev-parse master >expected_pub && + git -C submodule.git rev-parse main >actual_submodule && + git -C pub.git rev-parse main >actual_pub && + git -C work/gar/bage rev-parse main >expected_submodule && + git -C work rev-parse main >expected_pub && test_cmp expected_submodule actual_submodule && test_cmp expected_pub actual_pub ' @@ -548,7 +551,7 @@ test_expect_success 'push propagating refspec to a submodule' ' test_must_fail git -C work push --recurse-submodules=on-demand origin \ HEAD:refs/heads/branch2 && - git -C work/gar/bage branch branch2 master && + git -C work/gar/bage branch branch2 main && git -C work push --recurse-submodules=on-demand origin branch2 && git -C submodule.git rev-parse branch2 >actual_submodule && |