t2*: adjust the references to the default branch name "main"

Carefully excluding t2106, which sees independent development elsewhere
at the time of writing, we transition above-mentioned tests to the
default branch name `main`. This trick was performed via

	$ (cd t &&
	   sed -i -e 's/master/main/g' -e 's/MASTER/MAIN/g' \
		-e 's/Master/Main/g' -- t2*.sh &&
	   git checkout HEAD -- t2106\*)

This allows us to define `GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main`
for those tests.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin
2020-11-18 23:44:22 +00:00
committed by Junio C Hamano
parent 06d531486e
commit 883b98efad
19 changed files with 219 additions and 219 deletions

View File

@ -4,7 +4,7 @@
test_description='git checkout to switch between branches with symlink<->dir' test_description='git checkout to switch between branches with symlink<->dir'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -15,14 +15,14 @@ test_expect_success setup '
echo hello >frotz/filfre && echo hello >frotz/filfre &&
git add frotz/filfre && git add frotz/filfre &&
test_tick && test_tick &&
git commit -m "master has file frotz/filfre" && git commit -m "main has file frotz/filfre" &&
git branch side && git branch side &&
echo goodbye >nitfol && echo goodbye >nitfol &&
git add nitfol && git add nitfol &&
test_tick && test_tick &&
git commit -m "master adds file nitfol" && git commit -m "main adds file nitfol" &&
git checkout side && git checkout side &&
@ -37,13 +37,13 @@ test_expect_success setup '
test_expect_success 'switch from symlink to dir' ' test_expect_success 'switch from symlink to dir' '
git checkout master git checkout main
' '
test_expect_success 'Remove temporary directories & switch to master' ' test_expect_success 'Remove temporary directories & switch to main' '
rm -fr frotz xyzzy nitfol && rm -fr frotz xyzzy nitfol &&
git checkout -f master git checkout -f main
' '
test_expect_success 'switch from dir to symlink' ' test_expect_success 'switch from dir to symlink' '

View File

@ -2,7 +2,7 @@
test_description='checkout should leave clean stat info' test_description='checkout should leave clean stat info'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -24,13 +24,13 @@ test_expect_success 'branch switching' '
git reset --hard && git reset --hard &&
test "$(git diff-files --raw)" = "" && test "$(git diff-files --raw)" = "" &&
git checkout master && git checkout main &&
test "$(git diff-files --raw)" = "" && test "$(git diff-files --raw)" = "" &&
git checkout side && git checkout side &&
test "$(git diff-files --raw)" = "" && test "$(git diff-files --raw)" = "" &&
git checkout master && git checkout main &&
test "$(git diff-files --raw)" = "" test "$(git diff-files --raw)" = ""
' '
@ -40,13 +40,13 @@ test_expect_success 'path checkout' '
git reset --hard && git reset --hard &&
test "$(git diff-files --raw)" = "" && test "$(git diff-files --raw)" = "" &&
git checkout master world && git checkout main world &&
test "$(git diff-files --raw)" = "" && test "$(git diff-files --raw)" = "" &&
git checkout side world && git checkout side world &&
test "$(git diff-files --raw)" = "" && test "$(git diff-files --raw)" = "" &&
git checkout master world && git checkout main world &&
test "$(git diff-files --raw)" = "" test "$(git diff-files --raw)" = ""
' '

View File

@ -2,7 +2,7 @@
test_description='checkout and pathspecs/refspecs ambiguities' test_description='checkout and pathspecs/refspecs ambiguities'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -20,7 +20,7 @@ test_expect_success 'reference must be a tree' '
' '
test_expect_success 'branch switching' ' test_expect_success 'branch switching' '
test "refs/heads/master" = "$(git symbolic-ref HEAD)" && test "refs/heads/main" = "$(git symbolic-ref HEAD)" &&
git checkout world -- && git checkout world -- &&
test "refs/heads/world" = "$(git symbolic-ref HEAD)" test "refs/heads/world" = "$(git symbolic-ref HEAD)"
' '
@ -60,7 +60,7 @@ test_expect_success 'disambiguate checking out from a tree-ish' '
' '
test_expect_success 'accurate error message with more than one ref' ' test_expect_success 'accurate error message with more than one ref' '
test_must_fail git checkout HEAD master -- 2>actual && test_must_fail git checkout HEAD main -- 2>actual &&
test_i18ngrep 2 actual && test_i18ngrep 2 actual &&
test_i18ngrep "one reference expected, 2 given" actual test_i18ngrep "one reference expected, 2 given" actual
' '

View File

@ -2,7 +2,7 @@
test_description='checkout switching away from an invalid branch' test_description='checkout switching away from an invalid branch'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -14,12 +14,12 @@ test_expect_success 'setup' '
' '
test_expect_success 'checkout should not start branch from a tree' ' test_expect_success 'checkout should not start branch from a tree' '
test_must_fail git checkout -b newbranch master^{tree} test_must_fail git checkout -b newbranch main^{tree}
' '
test_expect_success 'checkout master from invalid HEAD' ' test_expect_success 'checkout main from invalid HEAD' '
echo $ZERO_OID >.git/HEAD && echo $ZERO_OID >.git/HEAD &&
git checkout master -- git checkout main --
' '
test_expect_success 'checkout notices failure to lock HEAD' ' test_expect_success 'checkout notices failure to lock HEAD' '
@ -29,7 +29,7 @@ test_expect_success 'checkout notices failure to lock HEAD' '
' '
test_expect_success 'create ref directory/file conflict scenario' ' test_expect_success 'create ref directory/file conflict scenario' '
git update-ref refs/heads/outer/inner master && git update-ref refs/heads/outer/inner main &&
# do not rely on symbolic-ref to get a known state, # do not rely on symbolic-ref to get a known state,
# as it may use the same code we are testing # as it may use the same code we are testing
@ -40,12 +40,12 @@ test_expect_success 'create ref directory/file conflict scenario' '
test_expect_success 'checkout away from d/f HEAD (unpacked, to branch)' ' test_expect_success 'checkout away from d/f HEAD (unpacked, to branch)' '
reset_to_df && reset_to_df &&
git checkout master git checkout main
' '
test_expect_success 'checkout away from d/f HEAD (unpacked, to detached)' ' test_expect_success 'checkout away from d/f HEAD (unpacked, to detached)' '
reset_to_df && reset_to_df &&
git checkout --detach master git checkout --detach main
' '
test_expect_success 'pack refs' ' test_expect_success 'pack refs' '
@ -54,11 +54,11 @@ test_expect_success 'pack refs' '
test_expect_success 'checkout away from d/f HEAD (packed, to branch)' ' test_expect_success 'checkout away from d/f HEAD (packed, to branch)' '
reset_to_df && reset_to_df &&
git checkout master git checkout main
' '
test_expect_success 'checkout away from d/f HEAD (packed, to detached)' ' test_expect_success 'checkout away from d/f HEAD (packed, to detached)' '
reset_to_df && reset_to_df &&
git checkout --detach master git checkout --detach main
' '
test_done test_done

View File

@ -2,7 +2,7 @@
test_description='checkout can switch to last branch and merge base' test_description='checkout can switch to last branch and merge base'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -27,7 +27,7 @@ test_expect_success 'first branch switch' '
test_expect_success '"checkout -" switches back' ' test_expect_success '"checkout -" switches back' '
git checkout - && git checkout - &&
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master" test "z$(git symbolic-ref HEAD)" = "zrefs/heads/main"
' '
test_expect_success '"checkout -" switches forth' ' test_expect_success '"checkout -" switches forth' '
@ -101,56 +101,56 @@ test_expect_success 'merge base test setup' '
git commit -m third git commit -m third
' '
test_expect_success 'another...master' ' test_expect_success 'another...main' '
git checkout another && git checkout another &&
git checkout another...master && git checkout another...main &&
test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)" test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify main^)"
' '
test_expect_success '...master' ' test_expect_success '...main' '
git checkout another && git checkout another &&
git checkout ...master && git checkout ...main &&
test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)" test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify main^)"
' '
test_expect_success 'master...' ' test_expect_success 'main...' '
git checkout another && git checkout another &&
git checkout master... && git checkout main... &&
test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)" test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify main^)"
' '
test_expect_success '"checkout -" works after a rebase A' ' test_expect_success '"checkout -" works after a rebase A' '
git checkout master && git checkout main &&
git checkout other && git checkout other &&
git rebase master && git rebase main &&
git checkout - && git checkout - &&
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master" test "z$(git symbolic-ref HEAD)" = "zrefs/heads/main"
' '
test_expect_success '"checkout -" works after a rebase A B' ' test_expect_success '"checkout -" works after a rebase A B' '
git branch moodle master~1 && git branch moodle main~1 &&
git checkout master && git checkout main &&
git checkout other && git checkout other &&
git rebase master moodle && git rebase main moodle &&
git checkout - && git checkout - &&
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master" test "z$(git symbolic-ref HEAD)" = "zrefs/heads/main"
' '
test_expect_success '"checkout -" works after a rebase -i A' ' test_expect_success '"checkout -" works after a rebase -i A' '
git checkout master && git checkout main &&
git checkout other && git checkout other &&
git rebase -i master && git rebase -i main &&
git checkout - && git checkout - &&
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master" test "z$(git symbolic-ref HEAD)" = "zrefs/heads/main"
' '
test_expect_success '"checkout -" works after a rebase -i A B' ' test_expect_success '"checkout -" works after a rebase -i A B' '
git branch foodle master~1 && git branch foodle main~1 &&
git checkout master && git checkout main &&
git checkout other && git checkout other &&
git rebase master foodle && git rebase main foodle &&
git checkout - && git checkout - &&
test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master" test "z$(git symbolic-ref HEAD)" = "zrefs/heads/main"
' '
test_done test_done

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
test_description='checkout from unborn branch' test_description='checkout from unborn branch'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -14,7 +14,7 @@ test_expect_success 'setup' '
git add file && git add file &&
git commit -m base git commit -m base
) && ) &&
git fetch parent master:origin git fetch parent main:origin
' '
test_expect_success 'checkout from unborn preserves untracked files' ' test_expect_success 'checkout from unborn preserves untracked files' '

View File

@ -7,7 +7,7 @@ test_description='git checkout --orphan
Main Tests for --orphan functionality.' Main Tests for --orphan functionality.'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -32,34 +32,34 @@ test_expect_success '--orphan creates a new orphan branch from HEAD' '
test_tick && test_tick &&
git commit -m "Third Commit" && git commit -m "Third Commit" &&
test_must_fail git rev-parse --verify HEAD^ && 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>' ' test_expect_success '--orphan creates a new orphan branch from <start_point>' '
git checkout master && git checkout main &&
git checkout --orphan beta master^ && git checkout --orphan beta main^ &&
test_must_fail git rev-parse --verify HEAD && test_must_fail git rev-parse --verify HEAD &&
test "refs/heads/beta" = "$(git symbolic-ref HEAD)" && test "refs/heads/beta" = "$(git symbolic-ref HEAD)" &&
test_tick && test_tick &&
git commit -m "Fourth Commit" && git commit -m "Fourth Commit" &&
test_must_fail git rev-parse --verify HEAD^ && 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' ' 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_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' ' test_expect_success '--orphan must be rejected with -t' '
git checkout master && git checkout main &&
test_must_fail git checkout --orphan new -t master && test_must_fail git checkout --orphan new -t main &&
test refs/heads/master = "$(git symbolic-ref HEAD)" test refs/heads/main = "$(git symbolic-ref HEAD)"
' '
test_expect_success '--orphan ignores branch.autosetupmerge' ' test_expect_success '--orphan ignores branch.autosetupmerge' '
git checkout master && git checkout main &&
git config branch.autosetupmerge always && git config branch.autosetupmerge always &&
git checkout --orphan gamma && git checkout --orphan gamma &&
test -z "$(git config branch.gamma.merge)" && test -z "$(git config branch.gamma.merge)" &&
@ -68,7 +68,7 @@ test_expect_success '--orphan ignores branch.autosetupmerge' '
' '
test_expect_success '--orphan makes reflog by default' ' test_expect_success '--orphan makes reflog by default' '
git checkout master && git checkout main &&
git config --unset core.logAllRefUpdates && git config --unset core.logAllRefUpdates &&
git checkout --orphan delta && git checkout --orphan delta &&
test_must_fail git rev-parse --verify delta@{0} && test_must_fail git rev-parse --verify delta@{0} &&
@ -77,7 +77,7 @@ test_expect_success '--orphan makes reflog by default' '
' '
test_expect_success '--orphan does not make reflog when core.logAllRefUpdates = false' ' test_expect_success '--orphan does not make reflog when core.logAllRefUpdates = false' '
git checkout master && git checkout main &&
git config core.logAllRefUpdates false && git config core.logAllRefUpdates false &&
git checkout --orphan epsilon && git checkout --orphan epsilon &&
test_must_fail git rev-parse --verify epsilon@{0} && test_must_fail git rev-parse --verify epsilon@{0} &&
@ -86,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' ' test_expect_success '--orphan with -l makes reflog when core.logAllRefUpdates = false' '
git checkout master && git checkout main &&
git checkout -l --orphan zeta && git checkout -l --orphan zeta &&
test_must_fail git rev-parse --verify zeta@{0} && test_must_fail git rev-parse --verify zeta@{0} &&
git commit -m Zeta && git commit -m Zeta &&
@ -94,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' ' 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 && git checkout -l --orphan eta &&
test_must_fail git rev-parse --verify eta@{0} && 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_must_fail git rev-parse --verify eta@{0}
' '
test_expect_success '--orphan is rejected with an existing name' ' test_expect_success '--orphan is rejected with an existing name' '
git checkout master && git checkout main &&
test_must_fail git checkout --orphan master && test_must_fail git checkout --orphan main &&
test refs/heads/master = "$(git symbolic-ref HEAD)" test refs/heads/main = "$(git symbolic-ref HEAD)"
' '
test_expect_success '--orphan refuses to switch if a merge is needed' ' test_expect_success '--orphan refuses to switch if a merge is needed' '
git checkout master && git checkout main &&
git reset --hard && git reset --hard &&
echo local >>"$TEST_FILE" && echo local >>"$TEST_FILE" &&
cat "$TEST_FILE" >"$TEST_FILE.saved" && cat "$TEST_FILE" >"$TEST_FILE.saved" &&
test_must_fail git checkout --orphan new master^ && test_must_fail git checkout --orphan new main^ &&
test refs/heads/master = "$(git symbolic-ref HEAD)" && test refs/heads/main = "$(git symbolic-ref HEAD)" &&
test_cmp "$TEST_FILE" "$TEST_FILE.saved" && test_cmp "$TEST_FILE" "$TEST_FILE.saved" &&
git diff-index --quiet --cached HEAD && git diff-index --quiet --cached HEAD &&
git reset --hard git reset --hard
' '
test_expect_success 'cannot --detach on an unborn branch' ' test_expect_success 'cannot --detach on an unborn branch' '
git checkout master && git checkout main &&
git checkout --orphan new && git checkout --orphan new &&
test_must_fail git checkout --detach test_must_fail git checkout --detach
' '

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
test_description='checkout into detached HEAD state' test_description='checkout into detached HEAD state'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -25,7 +25,7 @@ check_no_orphan_warning() {
} }
reset () { reset () {
git checkout master && git checkout main &&
check_not_detached check_not_detached
} }
@ -88,7 +88,7 @@ test_expect_success 'checkout --detach errors out for non-commit' '
test_expect_success 'checkout --detach errors out for extra argument' ' test_expect_success 'checkout --detach errors out for extra argument' '
reset && reset &&
git checkout master && git checkout main &&
test_must_fail git checkout --detach tag one.t && test_must_fail git checkout --detach tag one.t &&
check_not_detached check_not_detached
' '
@ -116,7 +116,7 @@ test_expect_success 'checkout warns on orphan commits' '
echo new content >orphan && echo new content >orphan &&
git commit -a -m orphan2 && git commit -a -m orphan2 &&
orphan2=$(git rev-parse HEAD) && orphan2=$(git rev-parse HEAD) &&
git checkout master 2>stderr git checkout main 2>stderr
' '
test_expect_success 'checkout warns on orphan commits: output' ' test_expect_success 'checkout warns on orphan commits: output' '
@ -135,7 +135,7 @@ test_expect_success 'checkout warns orphaning 1 of 2 commits: output' '
test_expect_success 'checkout does not warn leaving ref tip' ' test_expect_success 'checkout does not warn leaving ref tip' '
reset && reset &&
git checkout --detach two && git checkout --detach two &&
git checkout master 2>stderr git checkout main 2>stderr
' '
test_expect_success 'checkout does not warn leaving ref tip' ' test_expect_success 'checkout does not warn leaving ref tip' '
@ -145,7 +145,7 @@ test_expect_success 'checkout does not warn leaving ref tip' '
test_expect_success 'checkout does not warn leaving reachable commit' ' test_expect_success 'checkout does not warn leaving reachable commit' '
reset && reset &&
git checkout --detach HEAD^ && git checkout --detach HEAD^ &&
git checkout master 2>stderr git checkout main 2>stderr
' '
test_expect_success 'checkout does not warn leaving reachable commit' ' test_expect_success 'checkout does not warn leaving reachable commit' '
@ -153,14 +153,14 @@ test_expect_success 'checkout does not warn leaving reachable commit' '
' '
cat >expect <<'EOF' cat >expect <<'EOF'
Your branch is behind 'master' by 1 commit, and can be fast-forwarded. Your branch is behind 'main' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch) (use "git pull" to update your local branch)
EOF EOF
test_expect_success 'tracking count is accurate after orphan check' ' test_expect_success 'tracking count is accurate after orphan check' '
reset && reset &&
git branch child master^ && git branch child main^ &&
git config branch.child.remote . && git config branch.child.remote . &&
git config branch.child.merge refs/heads/master && git config branch.child.merge refs/heads/main &&
git checkout child^ && git checkout child^ &&
git checkout child >stdout && git checkout child >stdout &&
test_i18ncmp expect stdout test_i18ncmp expect stdout
@ -192,9 +192,9 @@ test_expect_success 'no advice given for explicit detached head state' '
# Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (new format) # Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (new format)
test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not asked to' " test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not asked to' "
commit=$(git rev-parse --short=12 master^) && commit=$(git rev-parse --short=12 main^) &&
commit2=$(git rev-parse --short=12 master~2) && commit2=$(git rev-parse --short=12 main~2) &&
commit3=$(git rev-parse --short=12 master~3) && commit3=$(git rev-parse --short=12 main~3) &&
# The first detach operation is more chatty than the following ones. # The first detach operation is more chatty than the following ones.
cat >1st_detach <<-EOF && cat >1st_detach <<-EOF &&
@ -274,9 +274,9 @@ test_expect_success 'describe_detached_head prints no SHA-1 ellipsis when not as
# Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (old format) # Detached HEAD tests for GIT_PRINT_SHA1_ELLIPSIS (old format)
test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked to' " test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked to' "
commit=$(git rev-parse --short=12 master^) && commit=$(git rev-parse --short=12 main^) &&
commit2=$(git rev-parse --short=12 master~2) && commit2=$(git rev-parse --short=12 main~2) &&
commit3=$(git rev-parse --short=12 master~3) && commit3=$(git rev-parse --short=12 main~3) &&
# The first detach operation is more chatty than the following ones. # The first detach operation is more chatty than the following ones.
cat >1st_detach <<-EOF && cat >1st_detach <<-EOF &&

View File

@ -1,22 +1,22 @@
#!/bin/sh #!/bin/sh
test_description='checkout $tree -- $paths' test_description='checkout $tree -- $paths'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
test_expect_success setup ' test_expect_success setup '
mkdir dir && mkdir dir &&
>dir/master && >dir/main &&
echo common >dir/common && echo common >dir/common &&
git add dir/master dir/common && git add dir/main dir/common &&
test_tick && git commit -m "master has dir/master" && test_tick && git commit -m "main has dir/main" &&
git checkout -b next && git checkout -b next &&
git mv dir/master dir/next0 && git mv dir/main dir/next0 &&
echo next >dir/next1 && echo next >dir/next1 &&
git add dir && git add dir &&
test_tick && git commit -m "next has dir/next but not dir/master" test_tick && git commit -m "next has dir/next but not dir/main"
' '
test_expect_success 'checking out paths out of a tree does not clobber unrelated paths' ' test_expect_success 'checking out paths out of a tree does not clobber unrelated paths' '
@ -29,11 +29,11 @@ test_expect_success 'checking out paths out of a tree does not clobber unrelated
echo untracked >expect.next2 && echo untracked >expect.next2 &&
cat expect.next2 >dir/next2 && cat expect.next2 >dir/next2 &&
git checkout master dir && git checkout main dir &&
test_cmp expect.common dir/common && test_cmp expect.common dir/common &&
test_path_is_file dir/master && test_path_is_file dir/main &&
git diff --exit-code master dir/master && git diff --exit-code main dir/main &&
test_path_is_missing dir/next0 && test_path_is_missing dir/next0 &&
test_cmp expect.next1 dir/next1 && test_cmp expect.next1 dir/next1 &&
@ -55,11 +55,11 @@ test_expect_success 'do not touch unmerged entries matching $path but not in $tr
EOF EOF
git update-index --index-info <expect.next0 && git update-index --index-info <expect.next0 &&
git checkout master dir && git checkout main dir &&
test_cmp expect.common dir/common && test_cmp expect.common dir/common &&
test_path_is_file dir/master && test_path_is_file dir/main &&
git diff --exit-code master dir/master && git diff --exit-code main dir/main &&
git ls-files -s dir/next0 >actual.next0 && git ls-files -s dir/next0 >actual.next0 &&
test_cmp expect.next0 actual.next0 test_cmp expect.next0 actual.next0
' '

View File

@ -4,7 +4,7 @@ test_description='checkout -m -- <conflicted path>
Ensures that checkout -m on a resolved file restores the conflicted file' Ensures that checkout -m on a resolved file restores the conflicted file'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -13,15 +13,15 @@ test_expect_success setup '
test_tick && test_tick &&
test_commit both.txt both.txt initial && test_commit both.txt both.txt initial &&
git branch topic && git branch topic &&
test_commit modified_in_master both.txt in_master && test_commit modified_in_main both.txt in_main &&
test_commit added_in_master each.txt in_master && test_commit added_in_main each.txt in_main &&
git checkout topic && git checkout topic &&
test_commit modified_in_topic both.txt in_topic && test_commit modified_in_topic both.txt in_topic &&
test_commit added_in_topic each.txt in_topic test_commit added_in_topic each.txt in_topic
' '
test_expect_success 'git merge master' ' test_expect_success 'git merge main' '
test_must_fail git merge master test_must_fail git merge main
' '
clean_branchnames () { clean_branchnames () {
@ -64,7 +64,7 @@ test_expect_success 'force checkout a conflict file creates stage zero entry' '
git checkout topic && git checkout topic &&
echo c >a && echo c >a &&
C_OBJ=$(git hash-object a) && C_OBJ=$(git hash-object a) &&
git checkout -m master && git checkout -m main &&
test_cmp_rev :1:a $A_OBJ && test_cmp_rev :1:a $A_OBJ &&
test_cmp_rev :2:a $B_OBJ && test_cmp_rev :2:a $B_OBJ &&
test_cmp_rev :3:a $C_OBJ && test_cmp_rev :3:a $C_OBJ &&

View File

@ -29,11 +29,11 @@ status_uno_is_clean () {
} }
test_expect_success 'setup' ' test_expect_success 'setup' '
test_commit my_master && test_commit my_main &&
git init repo_a && git init repo_a &&
( (
cd repo_a && cd repo_a &&
test_commit a_master && test_commit a_main &&
git checkout -b foo && git checkout -b foo &&
test_commit a_foo && test_commit a_foo &&
git checkout -b bar && git checkout -b bar &&
@ -44,7 +44,7 @@ test_expect_success 'setup' '
git init repo_b && git init repo_b &&
( (
cd repo_b && cd repo_b &&
test_commit b_master && test_commit b_main &&
git checkout -b foo && git checkout -b foo &&
test_commit b_foo && test_commit b_foo &&
git checkout -b baz && git checkout -b baz &&
@ -60,23 +60,23 @@ test_expect_success 'setup' '
' '
test_expect_success 'checkout of non-existing branch fails' ' test_expect_success 'checkout of non-existing branch fails' '
git checkout -B master && git checkout -B main &&
test_might_fail git branch -D xyzzy && test_might_fail git branch -D xyzzy &&
test_must_fail git checkout xyzzy && test_must_fail git checkout xyzzy &&
status_uno_is_clean && status_uno_is_clean &&
test_must_fail git rev-parse --verify refs/heads/xyzzy && test_must_fail git rev-parse --verify refs/heads/xyzzy &&
test_branch master test_branch main
' '
test_expect_success 'checkout of branch from multiple remotes fails #1' ' test_expect_success 'checkout of branch from multiple remotes fails #1' '
git checkout -B master && git checkout -B main &&
test_might_fail git branch -D foo && test_might_fail git branch -D foo &&
test_must_fail git checkout foo && test_must_fail git checkout foo &&
status_uno_is_clean && status_uno_is_clean &&
test_must_fail git rev-parse --verify refs/heads/foo && test_must_fail git rev-parse --verify refs/heads/foo &&
test_branch master test_branch main
' '
test_expect_success 'when arg matches multiple remotes, do not fallback to interpreting as pathspec' ' test_expect_success 'when arg matches multiple remotes, do not fallback to interpreting as pathspec' '
@ -100,21 +100,21 @@ test_expect_success 'when arg matches multiple remotes, do not fallback to inter
' '
test_expect_success 'checkout of branch from multiple remotes fails with advice' ' test_expect_success 'checkout of branch from multiple remotes fails with advice' '
git checkout -B master && git checkout -B main &&
test_might_fail git branch -D foo && test_might_fail git branch -D foo &&
test_must_fail git checkout foo 2>stderr && test_must_fail git checkout foo 2>stderr &&
test_branch master && test_branch main &&
status_uno_is_clean && status_uno_is_clean &&
test_i18ngrep "^hint: " stderr && test_i18ngrep "^hint: " stderr &&
test_must_fail git -c advice.checkoutAmbiguousRemoteBranchName=false \ test_must_fail git -c advice.checkoutAmbiguousRemoteBranchName=false \
checkout foo 2>stderr && checkout foo 2>stderr &&
test_branch master && test_branch main &&
status_uno_is_clean && status_uno_is_clean &&
test_i18ngrep ! "^hint: " stderr test_i18ngrep ! "^hint: " stderr
' '
test_expect_success PERL 'checkout -p with multiple remotes does not print advice' ' test_expect_success PERL 'checkout -p with multiple remotes does not print advice' '
git checkout -B master && git checkout -B main &&
test_might_fail git branch -D foo && test_might_fail git branch -D foo &&
git checkout -p foo 2>stderr && git checkout -p foo 2>stderr &&
@ -123,7 +123,7 @@ test_expect_success PERL 'checkout -p with multiple remotes does not print advic
' '
test_expect_success 'checkout of branch from multiple remotes succeeds with checkout.defaultRemote #1' ' test_expect_success 'checkout of branch from multiple remotes succeeds with checkout.defaultRemote #1' '
git checkout -B master && git checkout -B main &&
status_uno_is_clean && status_uno_is_clean &&
test_might_fail git branch -D foo && test_might_fail git branch -D foo &&
@ -135,7 +135,7 @@ test_expect_success 'checkout of branch from multiple remotes succeeds with chec
' '
test_expect_success 'checkout of branch from a single remote succeeds #1' ' test_expect_success 'checkout of branch from a single remote succeeds #1' '
git checkout -B master && git checkout -B main &&
test_might_fail git branch -D bar && test_might_fail git branch -D bar &&
git checkout bar && git checkout bar &&
@ -146,7 +146,7 @@ test_expect_success 'checkout of branch from a single remote succeeds #1' '
' '
test_expect_success 'checkout of branch from a single remote succeeds #2' ' test_expect_success 'checkout of branch from a single remote succeeds #2' '
git checkout -B master && git checkout -B main &&
test_might_fail git branch -D baz && test_might_fail git branch -D baz &&
git checkout baz && git checkout baz &&
@ -157,33 +157,33 @@ test_expect_success 'checkout of branch from a single remote succeeds #2' '
' '
test_expect_success '--no-guess suppresses branch auto-vivification' ' test_expect_success '--no-guess suppresses branch auto-vivification' '
git checkout -B master && git checkout -B main &&
status_uno_is_clean && status_uno_is_clean &&
test_might_fail git branch -D bar && test_might_fail git branch -D bar &&
test_must_fail git checkout --no-guess bar && test_must_fail git checkout --no-guess bar &&
test_must_fail git rev-parse --verify refs/heads/bar && test_must_fail git rev-parse --verify refs/heads/bar &&
test_branch master test_branch main
' '
test_expect_success 'checkout.guess = false suppresses branch auto-vivification' ' test_expect_success 'checkout.guess = false suppresses branch auto-vivification' '
git checkout -B master && git checkout -B main &&
status_uno_is_clean && status_uno_is_clean &&
test_might_fail git branch -D bar && test_might_fail git branch -D bar &&
test_config checkout.guess false && test_config checkout.guess false &&
test_must_fail git checkout bar && test_must_fail git checkout bar &&
test_must_fail git rev-parse --verify refs/heads/bar && test_must_fail git rev-parse --verify refs/heads/bar &&
test_branch master test_branch main
' '
test_expect_success 'setup more remotes with unconventional refspecs' ' test_expect_success 'setup more remotes with unconventional refspecs' '
git checkout -B master && git checkout -B main &&
status_uno_is_clean && status_uno_is_clean &&
git init repo_c && git init repo_c &&
( (
cd repo_c && cd repo_c &&
test_commit c_master && test_commit c_main &&
git checkout -b bar && git checkout -b bar &&
test_commit c_bar && test_commit c_bar &&
git checkout -b spam && git checkout -b spam &&
@ -192,7 +192,7 @@ test_expect_success 'setup more remotes with unconventional refspecs' '
git init repo_d && git init repo_d &&
( (
cd repo_d && cd repo_d &&
test_commit d_master && test_commit d_main &&
git checkout -b baz && git checkout -b baz &&
test_commit d_baz && test_commit d_baz &&
git checkout -b eggs && git checkout -b eggs &&
@ -208,29 +208,29 @@ test_expect_success 'setup more remotes with unconventional refspecs' '
' '
test_expect_success 'checkout of branch from multiple remotes fails #2' ' test_expect_success 'checkout of branch from multiple remotes fails #2' '
git checkout -B master && git checkout -B main &&
status_uno_is_clean && status_uno_is_clean &&
test_might_fail git branch -D bar && test_might_fail git branch -D bar &&
test_must_fail git checkout bar && test_must_fail git checkout bar &&
status_uno_is_clean && status_uno_is_clean &&
test_must_fail git rev-parse --verify refs/heads/bar && test_must_fail git rev-parse --verify refs/heads/bar &&
test_branch master test_branch main
' '
test_expect_success 'checkout of branch from multiple remotes fails #3' ' test_expect_success 'checkout of branch from multiple remotes fails #3' '
git checkout -B master && git checkout -B main &&
status_uno_is_clean && status_uno_is_clean &&
test_might_fail git branch -D baz && test_might_fail git branch -D baz &&
test_must_fail git checkout baz && test_must_fail git checkout baz &&
status_uno_is_clean && status_uno_is_clean &&
test_must_fail git rev-parse --verify refs/heads/baz && test_must_fail git rev-parse --verify refs/heads/baz &&
test_branch master test_branch main
' '
test_expect_success 'checkout of branch from a single remote succeeds #3' ' test_expect_success 'checkout of branch from a single remote succeeds #3' '
git checkout -B master && git checkout -B main &&
status_uno_is_clean && status_uno_is_clean &&
test_might_fail git branch -D spam && test_might_fail git branch -D spam &&
@ -242,7 +242,7 @@ test_expect_success 'checkout of branch from a single remote succeeds #3' '
' '
test_expect_success 'checkout of branch from a single remote succeeds #4' ' test_expect_success 'checkout of branch from a single remote succeeds #4' '
git checkout -B master && git checkout -B main &&
status_uno_is_clean && status_uno_is_clean &&
test_might_fail git branch -D eggs && test_might_fail git branch -D eggs &&
@ -254,7 +254,7 @@ test_expect_success 'checkout of branch from a single remote succeeds #4' '
' '
test_expect_success 'checkout of branch with a file having the same name fails' ' test_expect_success 'checkout of branch with a file having the same name fails' '
git checkout -B master && git checkout -B main &&
status_uno_is_clean && status_uno_is_clean &&
test_might_fail git branch -D spam && test_might_fail git branch -D spam &&
@ -262,11 +262,11 @@ test_expect_success 'checkout of branch with a file having the same name fails'
test_must_fail git checkout spam && test_must_fail git checkout spam &&
status_uno_is_clean && status_uno_is_clean &&
test_must_fail git rev-parse --verify refs/heads/spam && test_must_fail git rev-parse --verify refs/heads/spam &&
test_branch master test_branch main
' '
test_expect_success 'checkout of branch with a file in subdir having the same name fails' ' test_expect_success 'checkout of branch with a file in subdir having the same name fails' '
git checkout -B master && git checkout -B main &&
status_uno_is_clean && status_uno_is_clean &&
test_might_fail git branch -D spam && test_might_fail git branch -D spam &&
@ -276,11 +276,11 @@ test_expect_success 'checkout of branch with a file in subdir having the same na
test_must_fail git -C sub checkout spam && test_must_fail git -C sub checkout spam &&
status_uno_is_clean && status_uno_is_clean &&
test_must_fail git rev-parse --verify refs/heads/spam && test_must_fail git rev-parse --verify refs/heads/spam &&
test_branch master test_branch main
' '
test_expect_success 'checkout <branch> -- succeeds, even if a file with the same name exists' ' test_expect_success 'checkout <branch> -- succeeds, even if a file with the same name exists' '
git checkout -B master && git checkout -B main &&
status_uno_is_clean && status_uno_is_clean &&
test_might_fail git branch -D spam && test_might_fail git branch -D spam &&
@ -294,7 +294,7 @@ test_expect_success 'checkout <branch> -- succeeds, even if a file with the same
test_expect_success 'loosely defined local base branch is reported correctly' ' test_expect_success 'loosely defined local base branch is reported correctly' '
git checkout master && git checkout main &&
status_uno_is_clean && status_uno_is_clean &&
git branch strict && git branch strict &&
git branch loose && git branch loose &&
@ -302,8 +302,8 @@ test_expect_success 'loosely defined local base branch is reported correctly' '
test_config branch.strict.remote . && test_config branch.strict.remote . &&
test_config branch.loose.remote . && test_config branch.loose.remote . &&
test_config branch.strict.merge refs/heads/master && test_config branch.strict.merge refs/heads/main &&
test_config branch.loose.merge master && test_config branch.loose.merge main &&
git checkout strict | sed -e "s/strict/BRANCHNAME/g" >expect && git checkout strict | sed -e "s/strict/BRANCHNAME/g" >expect &&
status_uno_is_clean && status_uno_is_clean &&

View File

@ -2,7 +2,7 @@
test_description='tests for git branch --track' test_description='tests for git branch --track'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -13,14 +13,14 @@ test_expect_success 'setup' '
' '
test_expect_success 'checkout --track -b creates a new tracking branch' ' test_expect_success 'checkout --track -b creates a new tracking branch' '
git checkout --track -b branch1 master && git checkout --track -b branch1 main &&
test $(git rev-parse --abbrev-ref HEAD) = branch1 && test $(git rev-parse --abbrev-ref HEAD) = branch1 &&
test $(git config --get branch.branch1.remote) = . && test $(git config --get branch.branch1.remote) = . &&
test $(git config --get branch.branch1.merge) = refs/heads/master test $(git config --get branch.branch1.merge) = refs/heads/main
' '
test_expect_success 'checkout --track -b rejects an extra path argument' ' test_expect_success 'checkout --track -b rejects an extra path argument' '
test_must_fail git checkout --track -b branch2 master one.t 2>err && test_must_fail git checkout --track -b branch2 main one.t 2>err &&
test_i18ngrep "cannot be used with updating paths" err test_i18ngrep "cannot be used with updating paths" err
' '

View File

@ -2,7 +2,7 @@
test_description='undoing resolution' test_description='undoing resolution'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -62,7 +62,7 @@ test_expect_success setup '
test_commit fourth fi/le fourth && test_commit fourth fi/le fourth &&
git checkout add-add && git checkout add-add &&
test_commit fifth add-differently && test_commit fifth add-differently &&
git checkout master git checkout main
' '
test_expect_success 'add records switch clears' ' test_expect_success 'add records switch clears' '
@ -186,8 +186,8 @@ test_expect_success 'rerere forget (binary)' '
' '
test_expect_success 'rerere forget (add-add conflict)' ' test_expect_success 'rerere forget (add-add conflict)' '
git checkout -f master && git checkout -f main &&
echo master >add-differently && echo main >add-differently &&
git add add-differently && git add add-differently &&
git commit -m "add differently" && git commit -m "add differently" &&
test_must_fail git merge fifth && test_must_fail git merge fifth &&

View File

@ -2,7 +2,7 @@
test_description='switch basic functionality' test_description='switch basic functionality'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -26,41 +26,41 @@ test_expect_success 'switch branch' '
' '
test_expect_success 'switch and detach' ' test_expect_success 'switch and detach' '
test_when_finished git switch master && test_when_finished git switch main &&
test_must_fail git switch master^{commit} && test_must_fail git switch main^{commit} &&
git switch --detach master^{commit} && git switch --detach main^{commit} &&
test_must_fail git symbolic-ref HEAD test_must_fail git symbolic-ref HEAD
' '
test_expect_success 'switch and detach current branch' ' test_expect_success 'switch and detach current branch' '
test_when_finished git switch master && test_when_finished git switch main &&
git switch master && git switch main &&
git switch --detach && git switch --detach &&
test_must_fail git symbolic-ref HEAD test_must_fail git symbolic-ref HEAD
' '
test_expect_success 'switch and create branch' ' test_expect_success 'switch and create branch' '
test_when_finished git switch master && test_when_finished git switch main &&
git switch -c temp master^ && git switch -c temp main^ &&
test_cmp_rev master^ refs/heads/temp && test_cmp_rev main^ refs/heads/temp &&
echo refs/heads/temp >expected-branch && echo refs/heads/temp >expected-branch &&
git symbolic-ref HEAD >actual-branch && git symbolic-ref HEAD >actual-branch &&
test_cmp expected-branch actual-branch test_cmp expected-branch actual-branch
' '
test_expect_success 'force create branch from HEAD' ' test_expect_success 'force create branch from HEAD' '
test_when_finished git switch master && test_when_finished git switch main &&
git switch --detach master && git switch --detach main &&
test_must_fail git switch -c temp && test_must_fail git switch -c temp &&
git switch -C temp && git switch -C temp &&
test_cmp_rev master refs/heads/temp && test_cmp_rev main refs/heads/temp &&
echo refs/heads/temp >expected-branch && echo refs/heads/temp >expected-branch &&
git symbolic-ref HEAD >actual-branch && git symbolic-ref HEAD >actual-branch &&
test_cmp expected-branch actual-branch test_cmp expected-branch actual-branch
' '
test_expect_success 'new orphan branch from empty' ' test_expect_success 'new orphan branch from empty' '
test_when_finished git switch master && test_when_finished git switch main &&
test_must_fail git switch --orphan new-orphan HEAD && test_must_fail git switch --orphan new-orphan HEAD &&
git switch --orphan new-orphan && git switch --orphan new-orphan &&
test_commit orphan && test_commit orphan &&
@ -72,7 +72,7 @@ test_expect_success 'new orphan branch from empty' '
' '
test_expect_success 'orphan branch works with --discard-changes' ' test_expect_success 'orphan branch works with --discard-changes' '
test_when_finished git switch master && test_when_finished git switch main &&
echo foo >foo.txt && echo foo >foo.txt &&
git switch --discard-changes --orphan new-orphan2 && git switch --discard-changes --orphan new-orphan2 &&
git ls-files >tracked-files && git ls-files >tracked-files &&
@ -80,7 +80,7 @@ test_expect_success 'orphan branch works with --discard-changes' '
' '
test_expect_success 'switching ignores file of same branch name' ' test_expect_success 'switching ignores file of same branch name' '
test_when_finished git switch master && test_when_finished git switch main &&
: >first-branch && : >first-branch &&
git switch first-branch && git switch first-branch &&
echo refs/heads/first-branch >expected && echo refs/heads/first-branch >expected &&
@ -89,7 +89,7 @@ test_expect_success 'switching ignores file of same branch name' '
' '
test_expect_success 'guess and create branch' ' test_expect_success 'guess and create branch' '
test_when_finished git switch master && test_when_finished git switch main &&
test_must_fail git switch --no-guess foo && test_must_fail git switch --no-guess foo &&
test_config checkout.guess false && test_config checkout.guess false &&
test_must_fail git switch foo && test_must_fail git switch foo &&

View File

@ -2,7 +2,7 @@
test_description='restore basic functionality' test_description='restore basic functionality'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -18,7 +18,7 @@ test_expect_success 'setup' '
echo ignored >ignored && echo ignored >ignored &&
echo /ignored >.gitignore && echo /ignored >.gitignore &&
git add one two .gitignore && git add one two .gitignore &&
git update-ref refs/heads/one master git update-ref refs/heads/one main
' '
test_expect_success 'restore without pathspec is not ok' ' test_expect_success 'restore without pathspec is not ok' '
@ -94,7 +94,7 @@ test_expect_success 'restore --ignore-unmerged ignores unmerged entries' '
git switch -c first && git switch -c first &&
echo first >unmerged && echo first >unmerged &&
git commit -am first && git commit -am first &&
git switch -c second master && git switch -c second main &&
echo second >unmerged && echo second >unmerged &&
git commit -am second && git commit -am second &&
test_must_fail git merge first && test_must_fail git merge first &&

View File

@ -2,7 +2,7 @@
test_description='test git worktree add' test_description='test git worktree add'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -15,12 +15,12 @@ test_expect_success 'setup' '
test_expect_success '"add" an existing worktree' ' test_expect_success '"add" an existing worktree' '
mkdir -p existing/subtree && 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' ' test_expect_success '"add" an existing empty worktree' '
mkdir existing_empty && 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' ' test_expect_success '"add" using shorthand - fails when no previous branch' '
@ -32,7 +32,7 @@ test_expect_success '"add" using - shorthand' '
echo hello >myworld && echo hello >myworld &&
git add myworld && git add myworld &&
git commit -m myworld && git commit -m myworld &&
git checkout master && git checkout main &&
git worktree add short-hand - && git worktree add short-hand - &&
echo refs/heads/newbranch >expect && echo refs/heads/newbranch >expect &&
git -C short-hand rev-parse --symbolic-full-name HEAD >actual && git -C short-hand rev-parse --symbolic-full-name HEAD >actual &&
@ -40,7 +40,7 @@ test_expect_success '"add" using - shorthand' '
' '
test_expect_success '"add" refuses to checkout locked branch' ' 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 zere &&
! test -d .git/worktrees/zere ! test -d .git/worktrees/zere
' '
@ -49,13 +49,13 @@ test_expect_success 'checking out paths not complaining about linked checkouts'
( (
cd existing_empty && cd existing_empty &&
echo dirty >>init.t && echo dirty >>init.t &&
git checkout master -- init.t git checkout main -- init.t
) )
' '
test_expect_success '"add" worktree' ' test_expect_success '"add" worktree' '
git rev-parse HEAD >expect && git rev-parse HEAD >expect &&
git worktree add --detach here master && git worktree add --detach here main &&
( (
cd here && cd here &&
test_cmp ../init.t init.t && test_cmp ../init.t init.t &&
@ -68,7 +68,7 @@ test_expect_success '"add" worktree' '
test_expect_success '"add" worktree with lock' ' test_expect_success '"add" worktree with lock' '
git rev-parse HEAD >expect && 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 test -f .git/worktrees/here-with-lock/locked
' '
@ -76,7 +76,7 @@ test_expect_success '"add" worktree from a subdir' '
( (
mkdir sub && mkdir sub &&
cd sub && cd sub &&
git worktree add --detach here master && git worktree add --detach here main &&
cd here && cd here &&
test_cmp ../../init.t init.t test_cmp ../../init.t init.t
) )
@ -85,19 +85,19 @@ test_expect_success '"add" worktree from a subdir' '
test_expect_success '"add" from a linked checkout' ' test_expect_success '"add" from a linked checkout' '
( (
cd here && cd here &&
git worktree add --detach nested-here master && git worktree add --detach nested-here main &&
cd nested-here && cd nested-here &&
git fsck git fsck
) )
' '
test_expect_success '"add" worktree creating new branch' ' test_expect_success '"add" worktree creating new branch' '
git worktree add -b newmaster there master && git worktree add -b newmain there main &&
( (
cd there && cd there &&
test_cmp ../init.t init.t && test_cmp ../init.t init.t &&
git symbolic-ref HEAD >actual && git symbolic-ref HEAD >actual &&
echo refs/heads/newmaster >expect && echo refs/heads/newmain >expect &&
test_cmp expect actual && test_cmp expect actual &&
git fsck git fsck
) )
@ -106,7 +106,7 @@ test_expect_success '"add" worktree creating new branch' '
test_expect_success 'die the same branch is already checked out' ' test_expect_success 'die the same branch is already checked out' '
( (
cd here && cd here &&
test_must_fail git checkout newmaster test_must_fail git checkout newmain
) )
' '
@ -115,20 +115,20 @@ test_expect_success SYMLINKS 'die the same branch is already checked out (symlin
ref=$(git -C there symbolic-ref HEAD) && ref=$(git -C there symbolic-ref HEAD) &&
rm "$head" && rm "$head" &&
ln -s "$ref" "$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' ' test_expect_success 'not die the same branch is already checked out' '
( (
cd here && 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' ' test_expect_success 'not die on re-checking out current branch' '
( (
cd there && cd there &&
git checkout newmaster git checkout newmain
) )
' '
@ -136,14 +136,14 @@ test_expect_success '"add" from a bare repo' '
( (
git clone --bare . bare && git clone --bare . bare &&
cd 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"' ' test_expect_success 'checkout from a bare repo without "add"' '
( (
cd bare && cd bare &&
test_must_fail git checkout master test_must_fail git checkout main
) )
' '
@ -151,7 +151,7 @@ test_expect_success '"add" default branch of a bare repo' '
( (
git clone --bare . bare2 && git clone --bare . bare2 &&
cd bare2 && cd bare2 &&
git worktree add ../there3 master git worktree add ../there3 main
) )
' '
@ -168,7 +168,7 @@ test_expect_success 'checkout with grafts' '
EOF EOF
git log --format=%s -2 >actual && git log --format=%s -2 >actual &&
test_cmp expected 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 && git --git-dir=grafted/.git log --format=%s -2 >actual &&
test_cmp expected actual test_cmp expected actual
' '
@ -229,34 +229,34 @@ test_expect_success '"add" no auto-vivify with --detach and <branch> omitted' '
' '
test_expect_success '"add" -b/-B mutually exclusive' ' 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_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_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' ' test_expect_success '"add -B" fails if the branch is checked out' '
git rev-parse newmaster >before && git rev-parse newmain >before &&
test_must_fail git worktree add -B newmaster bamboo master && test_must_fail git worktree add -B newmain bamboo main &&
git rev-parse newmaster >after && git rev-parse newmain >after &&
test_cmp before after test_cmp before after
' '
test_expect_success 'add -B' ' 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 && git -C bamboo2 symbolic-ref HEAD >actual &&
echo refs/heads/poodle >expected && echo refs/heads/poodle >expected &&
test_cmp expected actual && test_cmp expected actual &&
test_cmp_rev master^ poodle test_cmp_rev main^ poodle
' '
test_expect_success 'add --quiet' ' 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 test_must_be_empty actual
' '
@ -351,24 +351,24 @@ test_branch_upstream () {
test_expect_success '--track sets up tracking' ' test_expect_success '--track sets up tracking' '
test_when_finished rm -rf track && test_when_finished rm -rf track &&
git worktree add --track -b track track master && git worktree add --track -b track track main &&
test_branch_upstream track . master test_branch_upstream track . main
' '
# setup remote repository $1 and repository $2 with $1 set up as # 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 () { setup_remote_repo () {
git init $1 && git init $1 &&
( (
cd $1 && cd $1 &&
test_commit $1_master && test_commit $1_main &&
git checkout -b foo && git checkout -b foo &&
test_commit upstream_foo test_commit upstream_foo
) && ) &&
git init $2 && git init $2 &&
( (
cd $2 && cd $2 &&
test_commit $2_master && test_commit $2_main &&
git remote add $1 ../$1 && git remote add $1 ../$1 &&
git config remote.$1.fetch \ git config remote.$1.fetch \
"refs/heads/*:refs/remotes/$1/*" && "refs/heads/*:refs/remotes/$1/*" &&

View File

@ -2,7 +2,7 @@
test_description='prune $GIT_DIR/worktrees' test_description='prune $GIT_DIR/worktrees'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -90,7 +90,7 @@ test_expect_success 'not prune recent checkouts' '
test_expect_success 'not prune proper checkouts' ' test_expect_success 'not prune proper checkouts' '
test_when_finished rm -r .git/worktrees && test_when_finished rm -r .git/worktrees &&
git worktree add --detach "$PWD/nop" master && git worktree add --detach "$PWD/nop" main &&
git worktree prune && git worktree prune &&
test -d .git/worktrees/nop test -d .git/worktrees/nop
' '

View File

@ -2,7 +2,7 @@
test_description='test git worktree list' test_description='test git worktree list'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -24,7 +24,7 @@ test_expect_success 'rev-parse --git-common-dir on main worktree' '
test_expect_success 'rev-parse --git-path objects linked worktree' ' test_expect_success 'rev-parse --git-path objects linked worktree' '
echo "$(git rev-parse --show-toplevel)/.git/objects" >expect && echo "$(git rev-parse --show-toplevel)/.git/objects" >expect &&
test_when_finished "rm -rf linked-tree actual expect && git worktree prune" && test_when_finished "rm -rf linked-tree actual expect && git worktree prune" &&
git worktree add --detach linked-tree master && git worktree add --detach linked-tree main &&
git -C linked-tree rev-parse --git-path objects >actual && git -C linked-tree rev-parse --git-path objects >actual &&
test_cmp expect actual test_cmp expect actual
' '
@ -32,7 +32,7 @@ test_expect_success 'rev-parse --git-path objects linked worktree' '
test_expect_success '"list" all worktrees from main' ' test_expect_success '"list" all worktrees from main' '
echo "$(git rev-parse --show-toplevel) $(git rev-parse --short HEAD) [$(git symbolic-ref --short HEAD)]" >expect && echo "$(git rev-parse --show-toplevel) $(git rev-parse --short HEAD) [$(git symbolic-ref --short HEAD)]" >expect &&
test_when_finished "rm -rf here out actual expect && git worktree prune" && test_when_finished "rm -rf here out actual expect && git worktree prune" &&
git worktree add --detach here master && git worktree add --detach here main &&
echo "$(git -C here rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >>expect && echo "$(git -C here rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >>expect &&
git worktree list >out && git worktree list >out &&
sed "s/ */ /g" <out >actual && sed "s/ */ /g" <out >actual &&
@ -42,7 +42,7 @@ test_expect_success '"list" all worktrees from main' '
test_expect_success '"list" all worktrees from linked' ' test_expect_success '"list" all worktrees from linked' '
echo "$(git rev-parse --show-toplevel) $(git rev-parse --short HEAD) [$(git symbolic-ref --short HEAD)]" >expect && echo "$(git rev-parse --show-toplevel) $(git rev-parse --short HEAD) [$(git symbolic-ref --short HEAD)]" >expect &&
test_when_finished "rm -rf here out actual expect && git worktree prune" && test_when_finished "rm -rf here out actual expect && git worktree prune" &&
git worktree add --detach here master && git worktree add --detach here main &&
echo "$(git -C here rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >>expect && echo "$(git -C here rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >>expect &&
git -C here worktree list >out && git -C here worktree list >out &&
sed "s/ */ /g" <out >actual && sed "s/ */ /g" <out >actual &&
@ -55,7 +55,7 @@ test_expect_success '"list" all worktrees --porcelain' '
echo "branch $(git symbolic-ref HEAD)" >>expect && echo "branch $(git symbolic-ref HEAD)" >>expect &&
echo >>expect && echo >>expect &&
test_when_finished "rm -rf here actual expect && git worktree prune" && test_when_finished "rm -rf here actual expect && git worktree prune" &&
git worktree add --detach here master && git worktree add --detach here main &&
echo "worktree $(git -C here rev-parse --show-toplevel)" >>expect && echo "worktree $(git -C here rev-parse --show-toplevel)" >>expect &&
echo "HEAD $(git rev-parse HEAD)" >>expect && echo "HEAD $(git rev-parse HEAD)" >>expect &&
echo "detached" >>expect && echo "detached" >>expect &&
@ -66,8 +66,8 @@ test_expect_success '"list" all worktrees --porcelain' '
test_expect_success '"list" all worktrees with locked annotation' ' test_expect_success '"list" all worktrees with locked annotation' '
test_when_finished "rm -rf locked unlocked out && git worktree prune" && test_when_finished "rm -rf locked unlocked out && git worktree prune" &&
git worktree add --detach locked master && git worktree add --detach locked main &&
git worktree add --detach unlocked master && git worktree add --detach unlocked main &&
git worktree lock locked && git worktree lock locked &&
git worktree list >out && git worktree list >out &&
grep "/locked *[0-9a-f].* locked$" out && grep "/locked *[0-9a-f].* locked$" out &&
@ -79,13 +79,13 @@ test_expect_success 'bare repo setup' '
echo "data" >file1 && echo "data" >file1 &&
git add file1 && git add file1 &&
git commit -m"File1: add data" && git commit -m"File1: add data" &&
git push bare1 master && git push bare1 main &&
git reset --hard HEAD^ git reset --hard HEAD^
' '
test_expect_success '"list" all worktrees from bare main' ' test_expect_success '"list" all worktrees from bare main' '
test_when_finished "rm -rf there out actual expect && git -C bare1 worktree prune" && test_when_finished "rm -rf there out actual expect && git -C bare1 worktree prune" &&
git -C bare1 worktree add --detach ../there master && git -C bare1 worktree add --detach ../there main &&
echo "$(pwd)/bare1 (bare)" >expect && echo "$(pwd)/bare1 (bare)" >expect &&
echo "$(git -C there rev-parse --show-toplevel) $(git -C there rev-parse --short HEAD) (detached HEAD)" >>expect && echo "$(git -C there rev-parse --show-toplevel) $(git -C there rev-parse --short HEAD) (detached HEAD)" >>expect &&
git -C bare1 worktree list >out && git -C bare1 worktree list >out &&
@ -95,7 +95,7 @@ test_expect_success '"list" all worktrees from bare main' '
test_expect_success '"list" all worktrees --porcelain from bare main' ' test_expect_success '"list" all worktrees --porcelain from bare main' '
test_when_finished "rm -rf there actual expect && git -C bare1 worktree prune" && test_when_finished "rm -rf there actual expect && git -C bare1 worktree prune" &&
git -C bare1 worktree add --detach ../there master && git -C bare1 worktree add --detach ../there main &&
echo "worktree $(pwd)/bare1" >expect && echo "worktree $(pwd)/bare1" >expect &&
echo "bare" >>expect && echo "bare" >>expect &&
echo >>expect && echo >>expect &&
@ -109,7 +109,7 @@ test_expect_success '"list" all worktrees --porcelain from bare main' '
test_expect_success '"list" all worktrees from linked with a bare main' ' test_expect_success '"list" all worktrees from linked with a bare main' '
test_when_finished "rm -rf there out actual expect && git -C bare1 worktree prune" && test_when_finished "rm -rf there out actual expect && git -C bare1 worktree prune" &&
git -C bare1 worktree add --detach ../there master && git -C bare1 worktree add --detach ../there main &&
echo "$(pwd)/bare1 (bare)" >expect && echo "$(pwd)/bare1 (bare)" >expect &&
echo "$(git -C there rev-parse --show-toplevel) $(git -C there rev-parse --short HEAD) (detached HEAD)" >>expect && echo "$(git -C there rev-parse --show-toplevel) $(git -C there rev-parse --short HEAD) (detached HEAD)" >>expect &&
git -C there worktree list >out && git -C there worktree list >out &&

View File

@ -2,7 +2,7 @@
test_description='Combination of submodules and multiple worktrees' test_description='Combination of submodules and multiple worktrees'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh . ./test-lib.sh
@ -34,7 +34,7 @@ test_expect_success 'add superproject worktree' '
' '
test_expect_failure 'submodule is checked out just after worktree add' ' test_expect_failure 'submodule is checked out just after worktree add' '
git -C worktree diff --submodule master"^!" >out && git -C worktree diff --submodule main"^!" >out &&
grep "file1 updated" out grep "file1 updated" out
' '
@ -44,7 +44,7 @@ test_expect_success 'add superproject worktree and initialize submodules' '
' '
test_expect_success 'submodule is checked out just after submodule update in linked worktree' ' test_expect_success 'submodule is checked out just after submodule update in linked worktree' '
git -C worktree-submodule-update diff --submodule master"^!" >out && git -C worktree-submodule-update diff --submodule main"^!" >out &&
grep "file1 updated" out grep "file1 updated" out
' '
@ -54,7 +54,7 @@ test_expect_success 'add superproject worktree and manually add submodule worktr
' '
test_expect_success 'submodule is checked out after manually adding submodule worktree' ' test_expect_success 'submodule is checked out after manually adding submodule worktree' '
git -C linked_submodule diff --submodule master"^!" >out && git -C linked_submodule diff --submodule main"^!" >out &&
grep "file1 updated" out grep "file1 updated" out
' '