summaryrefslogtreecommitdiff
path: root/t/t2017-checkout-orphan.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t2017-checkout-orphan.sh')
-rwxr-xr-xt/t2017-checkout-orphan.sh47
1 files changed, 25 insertions, 22 deletions
diff --git a/t/t2017-checkout-orphan.sh b/t/t2017-checkout-orphan.sh
index 655f278c5f..c7adbdd39a 100755
--- a/t/t2017-checkout-orphan.sh
+++ b/t/t2017-checkout-orphan.sh
@@ -7,6 +7,9 @@ test_description='git checkout --orphan
Main Tests for --orphan functionality.'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
. ./test-lib.sh
TEST_FILE=foo
@@ -29,34 +32,34 @@ test_expect_success '--orphan creates a new orphan branch from HEAD' '
test_tick &&
git commit -m "Third Commit" &&
test_must_fail git rev-parse --verify HEAD^ &&
- git diff-tree --quiet master alpha
+ git diff-tree --quiet main alpha
'
test_expect_success '--orphan creates a new orphan branch from <start_point>' '
- git checkout master &&
- git checkout --orphan beta master^ &&
+ git checkout main &&
+ git checkout --orphan beta main^ &&
test_must_fail git rev-parse --verify HEAD &&
test "refs/heads/beta" = "$(git symbolic-ref HEAD)" &&
test_tick &&
git commit -m "Fourth Commit" &&
test_must_fail git rev-parse --verify HEAD^ &&
- git diff-tree --quiet master^ beta
+ git diff-tree --quiet main^ beta
'
test_expect_success '--orphan must be rejected with -b' '
- git checkout master &&
+ git checkout main &&
test_must_fail git checkout --orphan new -b newer &&
- test refs/heads/master = "$(git symbolic-ref HEAD)"
+ test refs/heads/main = "$(git symbolic-ref HEAD)"
'
test_expect_success '--orphan must be rejected with -t' '
- git checkout master &&
- test_must_fail git checkout --orphan new -t master &&
- test refs/heads/master = "$(git symbolic-ref HEAD)"
+ git checkout main &&
+ test_must_fail git checkout --orphan new -t main &&
+ test refs/heads/main = "$(git symbolic-ref HEAD)"
'
test_expect_success '--orphan ignores branch.autosetupmerge' '
- git checkout master &&
+ git checkout main &&
git config branch.autosetupmerge always &&
git checkout --orphan gamma &&
test -z "$(git config branch.gamma.merge)" &&
@@ -65,7 +68,7 @@ test_expect_success '--orphan ignores branch.autosetupmerge' '
'
test_expect_success '--orphan makes reflog by default' '
- git checkout master &&
+ git checkout main &&
git config --unset core.logAllRefUpdates &&
git checkout --orphan delta &&
test_must_fail git rev-parse --verify delta@{0} &&
@@ -74,7 +77,7 @@ test_expect_success '--orphan makes reflog by default' '
'
test_expect_success '--orphan does not make reflog when core.logAllRefUpdates = false' '
- git checkout master &&
+ git checkout main &&
git config core.logAllRefUpdates false &&
git checkout --orphan epsilon &&
test_must_fail git rev-parse --verify epsilon@{0} &&
@@ -83,7 +86,7 @@ test_expect_success '--orphan does not make reflog when core.logAllRefUpdates =
'
test_expect_success '--orphan with -l makes reflog when core.logAllRefUpdates = false' '
- git checkout master &&
+ git checkout main &&
git checkout -l --orphan zeta &&
test_must_fail git rev-parse --verify zeta@{0} &&
git commit -m Zeta &&
@@ -91,33 +94,33 @@ test_expect_success '--orphan with -l makes reflog when core.logAllRefUpdates =
'
test_expect_success 'giving up --orphan not committed when -l and core.logAllRefUpdates = false deletes reflog' '
- git checkout master &&
+ git checkout main &&
git checkout -l --orphan eta &&
test_must_fail git rev-parse --verify eta@{0} &&
- git checkout master &&
+ git checkout main &&
test_must_fail git rev-parse --verify eta@{0}
'
test_expect_success '--orphan is rejected with an existing name' '
- git checkout master &&
- test_must_fail git checkout --orphan master &&
- test refs/heads/master = "$(git symbolic-ref HEAD)"
+ git checkout main &&
+ test_must_fail git checkout --orphan main &&
+ test refs/heads/main = "$(git symbolic-ref HEAD)"
'
test_expect_success '--orphan refuses to switch if a merge is needed' '
- git checkout master &&
+ git checkout main &&
git reset --hard &&
echo local >>"$TEST_FILE" &&
cat "$TEST_FILE" >"$TEST_FILE.saved" &&
- test_must_fail git checkout --orphan new master^ &&
- test refs/heads/master = "$(git symbolic-ref HEAD)" &&
+ test_must_fail git checkout --orphan new main^ &&
+ test refs/heads/main = "$(git symbolic-ref HEAD)" &&
test_cmp "$TEST_FILE" "$TEST_FILE.saved" &&
git diff-index --quiet --cached HEAD &&
git reset --hard
'
test_expect_success 'cannot --detach on an unborn branch' '
- git checkout master &&
+ git checkout main &&
git checkout --orphan new &&
test_must_fail git checkout --detach
'