diff options
Diffstat (limited to 't/t2400-worktree-add.sh')
-rwxr-xr-x | t/t2400-worktree-add.sh | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/t/t2400-worktree-add.sh b/t/t2400-worktree-add.sh index 5a7495474a..96dfca1554 100755 --- a/t/t2400-worktree-add.sh +++ b/t/t2400-worktree-add.sh @@ -2,6 +2,9 @@ test_description='test git worktree add' +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh @@ -12,12 +15,12 @@ test_expect_success 'setup' ' test_expect_success '"add" an existing worktree' ' mkdir -p existing/subtree && - test_must_fail git worktree add --detach existing master + test_must_fail git worktree add --detach existing main ' test_expect_success '"add" an existing empty worktree' ' mkdir existing_empty && - git worktree add --detach existing_empty master + git worktree add --detach existing_empty main ' test_expect_success '"add" using shorthand - fails when no previous branch' ' @@ -29,7 +32,7 @@ test_expect_success '"add" using - shorthand' ' echo hello >myworld && git add myworld && git commit -m myworld && - git checkout master && + git checkout main && git worktree add short-hand - && echo refs/heads/newbranch >expect && git -C short-hand rev-parse --symbolic-full-name HEAD >actual && @@ -37,7 +40,7 @@ test_expect_success '"add" using - shorthand' ' ' test_expect_success '"add" refuses to checkout locked branch' ' - test_must_fail git worktree add zere master && + test_must_fail git worktree add zere main && ! test -d zere && ! test -d .git/worktrees/zere ' @@ -46,13 +49,13 @@ test_expect_success 'checking out paths not complaining about linked checkouts' ( cd existing_empty && echo dirty >>init.t && - git checkout master -- init.t + git checkout main -- init.t ) ' test_expect_success '"add" worktree' ' git rev-parse HEAD >expect && - git worktree add --detach here master && + git worktree add --detach here main && ( cd here && test_cmp ../init.t init.t && @@ -65,7 +68,7 @@ test_expect_success '"add" worktree' ' test_expect_success '"add" worktree with lock' ' git rev-parse HEAD >expect && - git worktree add --detach --lock here-with-lock master && + git worktree add --detach --lock here-with-lock main && test -f .git/worktrees/here-with-lock/locked ' @@ -73,7 +76,7 @@ test_expect_success '"add" worktree from a subdir' ' ( mkdir sub && cd sub && - git worktree add --detach here master && + git worktree add --detach here main && cd here && test_cmp ../../init.t init.t ) @@ -82,19 +85,19 @@ test_expect_success '"add" worktree from a subdir' ' test_expect_success '"add" from a linked checkout' ' ( cd here && - git worktree add --detach nested-here master && + git worktree add --detach nested-here main && cd nested-here && git fsck ) ' test_expect_success '"add" worktree creating new branch' ' - git worktree add -b newmaster there master && + git worktree add -b newmain there main && ( cd there && test_cmp ../init.t init.t && git symbolic-ref HEAD >actual && - echo refs/heads/newmaster >expect && + echo refs/heads/newmain >expect && test_cmp expect actual && git fsck ) @@ -103,7 +106,7 @@ test_expect_success '"add" worktree creating new branch' ' test_expect_success 'die the same branch is already checked out' ' ( cd here && - test_must_fail git checkout newmaster + test_must_fail git checkout newmain ) ' @@ -112,20 +115,20 @@ test_expect_success SYMLINKS 'die the same branch is already checked out (symlin ref=$(git -C there symbolic-ref HEAD) && rm "$head" && ln -s "$ref" "$head" && - test_must_fail git -C here checkout newmaster + test_must_fail git -C here checkout newmain ' test_expect_success 'not die the same branch is already checked out' ' ( cd here && - git worktree add --force anothernewmaster newmaster + git worktree add --force anothernewmain newmain ) ' test_expect_success 'not die on re-checking out current branch' ' ( cd there && - git checkout newmaster + git checkout newmain ) ' @@ -133,14 +136,14 @@ test_expect_success '"add" from a bare repo' ' ( git clone --bare . bare && cd bare && - git worktree add -b bare-master ../there2 master + git worktree add -b bare-main ../there2 main ) ' test_expect_success 'checkout from a bare repo without "add"' ' ( cd bare && - test_must_fail git checkout master + test_must_fail git checkout main ) ' @@ -148,7 +151,7 @@ test_expect_success '"add" default branch of a bare repo' ' ( git clone --bare . bare2 && cd bare2 && - git worktree add ../there3 master + git worktree add ../there3 main ) ' @@ -165,7 +168,7 @@ test_expect_success 'checkout with grafts' ' EOF git log --format=%s -2 >actual && test_cmp expected actual && - git worktree add --detach grafted master && + git worktree add --detach grafted main && git --git-dir=grafted/.git log --format=%s -2 >actual && test_cmp expected actual ' @@ -226,34 +229,34 @@ test_expect_success '"add" no auto-vivify with --detach and <branch> omitted' ' ' test_expect_success '"add" -b/-B mutually exclusive' ' - test_must_fail git worktree add -b poodle -B poodle bamboo master + test_must_fail git worktree add -b poodle -B poodle bamboo main ' test_expect_success '"add" -b/--detach mutually exclusive' ' - test_must_fail git worktree add -b poodle --detach bamboo master + test_must_fail git worktree add -b poodle --detach bamboo main ' test_expect_success '"add" -B/--detach mutually exclusive' ' - test_must_fail git worktree add -B poodle --detach bamboo master + test_must_fail git worktree add -B poodle --detach bamboo main ' test_expect_success '"add -B" fails if the branch is checked out' ' - git rev-parse newmaster >before && - test_must_fail git worktree add -B newmaster bamboo master && - git rev-parse newmaster >after && + git rev-parse newmain >before && + test_must_fail git worktree add -B newmain bamboo main && + git rev-parse newmain >after && test_cmp before after ' test_expect_success 'add -B' ' - git worktree add -B poodle bamboo2 master^ && + git worktree add -B poodle bamboo2 main^ && git -C bamboo2 symbolic-ref HEAD >actual && echo refs/heads/poodle >expected && test_cmp expected actual && - test_cmp_rev master^ poodle + test_cmp_rev main^ poodle ' test_expect_success 'add --quiet' ' - git worktree add --quiet another-worktree master 2>actual && + git worktree add --quiet another-worktree main 2>actual && test_must_be_empty actual ' @@ -348,24 +351,24 @@ test_branch_upstream () { test_expect_success '--track sets up tracking' ' test_when_finished rm -rf track && - git worktree add --track -b track track master && - test_branch_upstream track . master + git worktree add --track -b track track main && + test_branch_upstream track . main ' # setup remote repository $1 and repository $2 with $1 set up as -# remote. The remote has two branches, master and foo. +# remote. The remote has two branches, main and foo. setup_remote_repo () { git init $1 && ( cd $1 && - test_commit $1_master && + test_commit $1_main && git checkout -b foo && test_commit upstream_foo ) && git init $2 && ( cd $2 && - test_commit $2_master && + test_commit $2_main && git remote add $1 ../$1 && git config remote.$1.fetch \ "refs/heads/*:refs/remotes/$1/*" && |