1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-22 03:56:33 +02:00

Merge branch 'js/default-branch-name-tests-final-stretch'

Prepare tests not to be affected by the name of the default branch
"git init" creates.

* js/default-branch-name-tests-final-stretch: (28 commits)
  tests: drop prereq `PREPARE_FOR_MAIN_BRANCH` where no longer needed
  t99*: adjust the references to the default branch name "main"
  tests(git-p4): transition to the default branch name `main`
  t9[5-7]*: adjust the references to the default branch name "main"
  t9[0-4]*: adjust the references to the default branch name "main"
  t8*: adjust the references to the default branch name "main"
  t7[5-9]*: adjust the references to the default branch name "main"
  t7[0-4]*: adjust the references to the default branch name "main"
  t6[4-9]*: adjust the references to the default branch name "main"
  t64*: preemptively adjust alignment to prepare for `master` -> `main`
  t6[0-3]*: adjust the references to the default branch name "main"
  t5[6-9]*: adjust the references to the default branch name "main"
  t55[4-9]*: adjust the references to the default branch name "main"
  t55[23]*: adjust the references to the default branch name "main"
  t551*: adjust the references to the default branch name "main"
  t550*: adjust the references to the default branch name "main"
  t5503: prepare aligned comment for replacing `master` with `main`
  t5[0-4]*: adjust the references to the default branch name "main"
  t5323: prepare centered comment for `master` -> `main`
  t4*: adjust the references to the default branch name "main"
  ...
This commit is contained in:
Junio C Hamano 2021-01-25 14:19:18 -08:00
commit 27d7c8599b
355 changed files with 4403 additions and 3436 deletions

View File

@ -13,6 +13,7 @@ esac
make
case "$jobname" in
linux-gcc)
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
make test
export GIT_TEST_SPLIT_INDEX=yes
export GIT_TEST_FULL_IN_PACK_ARRAY=true
@ -22,6 +23,7 @@ linux-gcc)
export GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=1
export GIT_TEST_MULTI_PACK_INDEX=1
export GIT_TEST_ADD_I_USE_BUILTIN=1
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
make test
;;
linux-clang)

View File

@ -95,7 +95,7 @@ test_expect_success 'blame 2 authors' '
'
test_expect_success 'setup B1 lines (branch1)' '
git checkout -b branch1 master &&
git checkout -b branch1 main &&
echo "3A slow green fox jumps into the" >>file &&
echo "well." >>file &&
GIT_AUTHOR_NAME="B1" GIT_AUTHOR_EMAIL="B1@test.git" \
@ -107,7 +107,7 @@ test_expect_success 'blame 2 authors + 1 branch1 author' '
'
test_expect_success 'setup B2 lines (branch2)' '
git checkout -b branch2 master &&
git checkout -b branch2 main &&
sed -e "s/2A quick brown/4A quick brown lazy dog/" <file >file.new &&
mv file.new file &&
GIT_AUTHOR_NAME="B2" GIT_AUTHOR_EMAIL="B2@test.git" \
@ -131,11 +131,11 @@ test_expect_success 'blame --first-parent blames merge for branch1' '
'
test_expect_success 'blame ancestor' '
check_count -h master A 2 B 2
check_count -h main A 2 B 2
'
test_expect_success 'blame great-ancestor' '
check_count -h master^ A 2
check_count -h main^ A 2
'
test_expect_success 'setup evil merge' '

View File

@ -36,7 +36,7 @@ setup_cvs_test_repository () {
test_cvs_co () {
# Usage: test_cvs_co BRANCH_NAME
rm -rf module-cvs-"$1"
if [ "$1" = "master" ]
if [ "$1" = "main" ]
then
$CVS co -P -d module-cvs-"$1" -A module
else

View File

@ -4,6 +4,9 @@ test_description='.git file
Verify that plumbing commands work when .git is a file
'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
objpath() {
@ -96,7 +99,7 @@ test_expect_success 'enter_repo non-strict mode' '
git ls-remote enter_repo >actual &&
cat >expected <<-EOF &&
$head HEAD
$head refs/heads/master
$head refs/heads/main
$head refs/tags/foo
EOF
test_cmp expected actual
@ -111,7 +114,7 @@ test_expect_success 'enter_repo linked checkout' '
git ls-remote foo >actual &&
cat >expected <<-EOF &&
$head HEAD
$head refs/heads/master
$head refs/heads/main
$head refs/tags/foo
EOF
test_cmp expected actual
@ -122,7 +125,7 @@ test_expect_success 'enter_repo strict mode' '
git ls-remote --upload-pack="git upload-pack --strict" foo/.git >actual &&
cat >expected <<-EOF &&
$head HEAD
$head refs/heads/master
$head refs/heads/main
$head refs/tags/foo
EOF
test_cmp expected actual

View File

@ -2,6 +2,9 @@
test_description='CRLF conversion'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
has_cr() {
@ -318,8 +321,8 @@ test_expect_success 'checkout with existing .gitattributes' '
git add .gitattributes .file &&
git commit -m second &&
git checkout master~1 &&
git checkout master &&
git checkout main~1 &&
git checkout main &&
test "$(git diff-files --raw)" = ""
'
@ -331,8 +334,8 @@ test_expect_success 'checkout when deleting .gitattributes' '
git add .file2 &&
git commit -m third &&
git checkout master~1 &&
git checkout master &&
git checkout main~1 &&
git checkout main &&
has_cr .file2
'

View File

@ -2,6 +2,9 @@
test_description='blob conversion via gitattributes'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
TEST_ROOT="$PWD"
@ -378,8 +381,8 @@ test_expect_success PERL 'required process filter should filter data' '
test_cmp_count expected.log debug.log &&
git commit -m "test commit 2" &&
MASTER=$(git rev-parse --verify master) &&
META="ref=refs/heads/master treeish=$MASTER" &&
MAIN=$(git rev-parse --verify main) &&
META="ref=refs/heads/main treeish=$MAIN" &&
rm -f test2.r "testsubdir/test3 '\''sq'\'',\$x=.r" &&
filter_git checkout --quiet --no-progress . &&
@ -404,7 +407,7 @@ test_expect_success PERL 'required process filter should filter data' '
EOF
test_cmp_exclude_clean expected.log debug.log &&
filter_git checkout --quiet --no-progress master &&
filter_git checkout --quiet --no-progress main &&
cat >expected.log <<-EOF &&
START
init handshake complete
@ -436,15 +439,15 @@ test_expect_success PERL 'required process filter should filter data for various
M3=$(git hash-object "testsubdir/test3 '\''sq'\'',\$x=.r") &&
EMPTY=$(git hash-object /dev/null) &&
MASTER=$(git rev-parse --verify master) &&
MAIN=$(git rev-parse --verify main) &&
cp "$TEST_ROOT/test.o" test5.r &&
git add test5.r &&
git commit -m "test commit 3" &&
git checkout empty-branch &&
filter_git rebase --onto empty-branch master^^ master &&
MASTER2=$(git rev-parse --verify master) &&
META="ref=refs/heads/master treeish=$MASTER2" &&
filter_git rebase --onto empty-branch main^^ main &&
MAIN2=$(git rev-parse --verify main) &&
META="ref=refs/heads/main treeish=$MAIN2" &&
cat >expected.log <<-EOF &&
START
init handshake complete
@ -458,8 +461,8 @@ test_expect_success PERL 'required process filter should filter data for various
test_cmp_exclude_clean expected.log debug.log &&
git reset --hard empty-branch &&
filter_git reset --hard $MASTER &&
META="treeish=$MASTER" &&
filter_git reset --hard $MAIN &&
META="treeish=$MAIN" &&
cat >expected.log <<-EOF &&
START
init handshake complete
@ -471,10 +474,10 @@ test_expect_success PERL 'required process filter should filter data for various
EOF
test_cmp_exclude_clean expected.log debug.log &&
git branch old-master $MASTER &&
git branch old-main $MAIN &&
git reset --hard empty-branch &&
filter_git reset --hard old-master &&
META="ref=refs/heads/old-master treeish=$MASTER" &&
filter_git reset --hard old-main &&
META="ref=refs/heads/old-main treeish=$MAIN" &&
cat >expected.log <<-EOF &&
START
init handshake complete
@ -487,9 +490,9 @@ test_expect_success PERL 'required process filter should filter data for various
test_cmp_exclude_clean expected.log debug.log &&
git checkout -b merge empty-branch &&
git branch -f master $MASTER2 &&
filter_git merge master &&
META="treeish=$MASTER2" &&
git branch -f main $MAIN2 &&
filter_git merge main &&
META="treeish=$MAIN2" &&
cat >expected.log <<-EOF &&
START
init handshake complete
@ -502,8 +505,8 @@ test_expect_success PERL 'required process filter should filter data for various
EOF
test_cmp_exclude_clean expected.log debug.log &&
filter_git archive master >/dev/null &&
META="ref=refs/heads/master treeish=$MASTER2" &&
filter_git archive main >/dev/null &&
META="ref=refs/heads/main treeish=$MAIN2" &&
cat >expected.log <<-EOF &&
START
init handshake complete
@ -516,7 +519,7 @@ test_expect_success PERL 'required process filter should filter data for various
EOF
test_cmp_exclude_clean expected.log debug.log &&
TREE="$(git rev-parse $MASTER2^{tree})" &&
TREE="$(git rev-parse $MAIN2^{tree})" &&
filter_git archive $TREE >/dev/null &&
META="treeish=$TREE" &&
cat >expected.log <<-EOF &&
@ -856,8 +859,8 @@ test_expect_success PERL 'delayed checkout in process filter' '
) &&
S=$(test_file_size "$TEST_ROOT/test.o") &&
PM="ref=refs/heads/master treeish=$(git -C repo rev-parse --verify master) " &&
M="${PM}blob=$(git -C repo rev-parse --verify master:test.a)" &&
PM="ref=refs/heads/main treeish=$(git -C repo rev-parse --verify main) " &&
M="${PM}blob=$(git -C repo rev-parse --verify main:test.a)" &&
cat >a.exp <<-EOF &&
START
init handshake complete

View File

@ -368,9 +368,9 @@ test_expect_success 'ls-files --eol -o Text/Binary' '
test_cmp expect actual
'
test_expect_success 'setup master' '
test_expect_success 'setup main' '
echo >.gitattributes &&
git checkout -b master &&
git checkout -b main &&
git add .gitattributes &&
git commit -m "add .gitattributes" . &&
printf "\$Id: 0000000000000000000000000000000000000000 \$\nLINEONE\nLINETWO\nLINETHREE" >LF &&

View File

@ -2,6 +2,9 @@
test_description='working-tree-encoding conversion via gitattributes'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
GIT_TRACE_WORKING_TREE_ENCODING=1 && export GIT_TRACE_WORKING_TREE_ENCODING
@ -215,7 +218,7 @@ test_expect_success 'error if encoding round trip is not the same during refresh
TEST_HASH=$(git hash-object --no-filters -w nonsense.utf16le) &&
git update-index --add --cacheinfo 100644 $TEST_HASH nonsense.utf16le &&
COMMIT=$(git commit-tree -p $(git rev-parse HEAD) -m "plain commit" $(git write-tree)) &&
git update-ref refs/heads/master $COMMIT &&
git update-ref refs/heads/main $COMMIT &&
test_must_fail git checkout HEAD^ 2>err.out &&
test_i18ngrep "error: .* overwritten by checkout:" err.out
@ -231,7 +234,7 @@ test_expect_success 'error if encoding garbage is already in Git' '
TEST_HASH=$(git hash-object --no-filters -w nonsense.utf16) &&
git update-index --add --cacheinfo 100644 $TEST_HASH nonsense.utf16 &&
COMMIT=$(git commit-tree -p $(git rev-parse HEAD) -m "plain commit" $(git write-tree)) &&
git update-ref refs/heads/master $COMMIT &&
git update-ref refs/heads/main $COMMIT &&
git diff 2>err.out &&
test_i18ngrep "error: BOM is required" err.out

View File

@ -2,6 +2,9 @@
test_description='Test commands behavior when given invalid argument value'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'setup ' '
@ -41,8 +44,8 @@ test_expect_success 'tag usage error' '
'
test_expect_success 'branch --contains <existent_commit>' '
git branch --contains "master" >actual 2>actual.err &&
test_i18ngrep "master" actual &&
git branch --contains "main" >actual 2>actual.err &&
test_i18ngrep "main" actual &&
test_line_count = 0 actual.err
'
@ -54,7 +57,7 @@ test_expect_success 'branch --contains <inexistent_commit>' '
'
test_expect_success 'branch --no-contains <existent_commit>' '
git branch --no-contains "master" >actual 2>actual.err &&
git branch --no-contains "main" >actual 2>actual.err &&
test_line_count = 0 actual &&
test_line_count = 0 actual.err
'
@ -73,7 +76,7 @@ test_expect_success 'branch usage error' '
'
test_expect_success 'for-each-ref --contains <existent_object>' '
git for-each-ref --contains "master" >actual 2>actual.err &&
git for-each-ref --contains "main" >actual 2>actual.err &&
test_line_count = 2 actual &&
test_line_count = 0 actual.err
'
@ -86,7 +89,7 @@ test_expect_success 'for-each-ref --contains <inexistent_object>' '
'
test_expect_success 'for-each-ref --no-contains <existent_object>' '
git for-each-ref --no-contains "master" >actual 2>actual.err &&
git for-each-ref --no-contains "main" >actual 2>actual.err &&
test_line_count = 0 actual &&
test_line_count = 0 actual.err
'

View File

@ -2,6 +2,9 @@
test_description='Various filesystem issues'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
auml=$(printf '\303\244')
@ -65,7 +68,7 @@ test_expect_success "setup case tests" '
git mv camelcase tmp &&
git mv tmp CamelCase &&
git commit -m "rename" &&
git checkout -f master
git checkout -f main
'
test_expect_success 'rename (case change)' '
@ -118,7 +121,7 @@ test_expect_success "setup unicode normalization tests" '
git mv $aumlcdiar tmp &&
git mv tmp "$auml" &&
git commit -m rename &&
git checkout -f master
git checkout -f main
'
$test_unicode 'rename (silent unicode normalization)' '
@ -147,7 +150,7 @@ test_expect_success CASE_INSENSITIVE_FS 'checkout with no pathspec and a case in
git add gitweb &&
git commit -m "add gitweb/subdir/file" &&
git checkout master
git checkout main
)
'

View File

@ -312,8 +312,8 @@ test_git_path GIT_COMMON_DIR=bar info/sparse-checkout .git/info/sparse-check
test_git_path GIT_COMMON_DIR=bar info//sparse-checkout .git/info//sparse-checkout
test_git_path GIT_COMMON_DIR=bar remotes/bar bar/remotes/bar
test_git_path GIT_COMMON_DIR=bar branches/bar bar/branches/bar
test_git_path GIT_COMMON_DIR=bar logs/refs/heads/master bar/logs/refs/heads/master
test_git_path GIT_COMMON_DIR=bar refs/heads/master bar/refs/heads/master
test_git_path GIT_COMMON_DIR=bar logs/refs/heads/main bar/logs/refs/heads/main
test_git_path GIT_COMMON_DIR=bar refs/heads/main bar/refs/heads/main
test_git_path GIT_COMMON_DIR=bar refs/bisect/foo .git/refs/bisect/foo
test_git_path GIT_COMMON_DIR=bar hooks/me bar/hooks/me
test_git_path GIT_COMMON_DIR=bar config bar/config

View File

@ -2,13 +2,16 @@
test_description='previous branch syntax @{-n}'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'branch -d @{-1}' '
test_commit A &&
git checkout -b junk &&
git checkout - &&
test "$(git symbolic-ref HEAD)" = refs/heads/master &&
test "$(git symbolic-ref HEAD)" = refs/heads/main &&
git branch -d @{-1} &&
test_must_fail git rev-parse --verify refs/heads/junk
'
@ -17,9 +20,9 @@ test_expect_success 'branch -d @{-12} when there is not enough switches yet' '
git reflog expire --expire=now &&
git checkout -b junk2 &&
git checkout - &&
test "$(git symbolic-ref HEAD)" = refs/heads/master &&
test "$(git symbolic-ref HEAD)" = refs/heads/main &&
test_must_fail git branch -d @{-12} &&
git rev-parse --verify refs/heads/master
git rev-parse --verify refs/heads/main
'
test_expect_success 'merge @{-1}' '
@ -28,19 +31,19 @@ test_expect_success 'merge @{-1}' '
git checkout A &&
test_commit C &&
test_commit D &&
git branch -f master B &&
git branch -f main B &&
git branch -f other &&
git checkout other &&
git checkout master &&
git checkout main &&
git merge @{-1} &&
git cat-file commit HEAD | grep "Merge branch '\''other'\''"
'
test_expect_success 'merge @{-1}~1' '
git checkout master &&
git checkout main &&
git reset --hard B &&
git checkout other &&
git checkout master &&
git checkout main &&
git merge @{-1}~1 &&
git cat-file commit HEAD >actual &&
grep "Merge branch '\''other'\''" actual
@ -48,11 +51,11 @@ test_expect_success 'merge @{-1}~1' '
test_expect_success 'merge @{-100} before checking out that many branches yet' '
git reflog expire --expire=now &&
git checkout -f master &&
git checkout -f main &&
git reset --hard B &&
git branch -f other C &&
git checkout other &&
git checkout master &&
git checkout main &&
test_must_fail git merge @{-100}
'

View File

@ -2,6 +2,9 @@
test_description='read-tree -m -u checks working tree files'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh
@ -20,17 +23,17 @@ test_expect_success 'two-way setup' '
git branch side &&
git tag -f branch-point &&
echo file2 is not tracked on the master branch anymore &&
echo file2 is not tracked on the main branch anymore &&
rm -f file2 subdir/file2 &&
git update-index --remove file2 subdir/file2 &&
git commit -a -m "master removes file2 and subdir/file2"
git commit -a -m "main removes file2 and subdir/file2"
'
test_expect_success 'two-way not clobbering' '
echo >file2 master creates untracked file2 &&
echo >subdir/file2 master creates untracked subdir/file2 &&
if err=$(read_tree_u_must_succeed -m -u master side 2>&1)
echo >file2 main creates untracked file2 &&
echo >subdir/file2 main creates untracked subdir/file2 &&
if err=$(read_tree_u_must_succeed -m -u main side 2>&1)
then
echo should have complained
false
@ -43,7 +46,7 @@ echo file2 >.gitignore
test_expect_success 'two-way with incorrect --exclude-per-directory (1)' '
if err=$(read_tree_u_must_succeed -m --exclude-per-directory=.gitignore master side 2>&1)
if err=$(read_tree_u_must_succeed -m --exclude-per-directory=.gitignore main side 2>&1)
then
echo should have complained
false
@ -54,7 +57,7 @@ test_expect_success 'two-way with incorrect --exclude-per-directory (1)' '
test_expect_success 'two-way with incorrect --exclude-per-directory (2)' '
if err=$(read_tree_u_must_succeed -m -u --exclude-per-directory=foo --exclude-per-directory=.gitignore master side 2>&1)
if err=$(read_tree_u_must_succeed -m -u --exclude-per-directory=foo --exclude-per-directory=.gitignore main side 2>&1)
then
echo should have complained
false
@ -65,7 +68,7 @@ test_expect_success 'two-way with incorrect --exclude-per-directory (2)' '
test_expect_success 'two-way clobbering a ignored file' '
read_tree_u_must_succeed -m -u --exclude-per-directory=.gitignore master side
read_tree_u_must_succeed -m -u --exclude-per-directory=.gitignore main side
'
rm -f .gitignore
@ -81,21 +84,21 @@ test_expect_success 'three-way not complaining on an untracked path in both' '
git update-index --add file3 subdir/file3 &&
git commit -a -m "side adds file3 and removes file2" &&
git checkout master &&
echo >file2 file two is untracked on the master side &&
echo >subdir/file2 file two is untracked on the master side &&
git checkout main &&
echo >file2 file two is untracked on the main side &&
echo >subdir/file2 file two is untracked on the main side &&
read_tree_u_must_succeed -m -u branch-point master side
read_tree_u_must_succeed -m -u branch-point main side
'
test_expect_success 'three-way not clobbering a working tree file' '
git reset --hard &&
rm -f file2 subdir/file2 file3 subdir/file3 &&
git checkout master &&
echo >file3 file three created in master, untracked &&
echo >subdir/file3 file three created in master, untracked &&
if err=$(read_tree_u_must_succeed -m -u branch-point master side 2>&1)
git checkout main &&
echo >file3 file three created in main, untracked &&
echo >subdir/file3 file three created in main, untracked &&
if err=$(read_tree_u_must_succeed -m -u branch-point main side 2>&1)
then
echo should have complained
false
@ -110,11 +113,11 @@ test_expect_success 'three-way not complaining on an untracked file' '
git reset --hard &&
rm -f file2 subdir/file2 file3 subdir/file3 &&
git checkout master &&
echo >file3 file three created in master, untracked &&
echo >subdir/file3 file three created in master, untracked &&
git checkout main &&
echo >file3 file three created in main, untracked &&
echo >subdir/file3 file three created in main, untracked &&
read_tree_u_must_succeed -m -u --exclude-per-directory=.gitignore branch-point master side
read_tree_u_must_succeed -m -u --exclude-per-directory=.gitignore branch-point main side
'
test_expect_success '3-way not overwriting local changes (setup)' '

View File

@ -2,6 +2,9 @@
test_description='test multi-tree read-tree without merging'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh
@ -22,7 +25,7 @@ test_expect_success setup '
'
test_expect_success 'multi-read' '
read_tree_must_succeed initial master side &&
read_tree_must_succeed initial main side &&
test_write_lines a b/c >expect &&
git ls-files >actual &&
test_cmp expect actual

View File

@ -2,6 +2,9 @@
test_description='test read-tree into a fresh index file'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '
@ -12,13 +15,13 @@ test_expect_success setup '
test_expect_success 'non-existent index file' '
rm -f new-index &&
GIT_INDEX_FILE=new-index git read-tree master
GIT_INDEX_FILE=new-index git read-tree main
'
test_expect_success 'empty index file' '
rm -f new-index &&
> new-index &&
GIT_INDEX_FILE=new-index git read-tree master
GIT_INDEX_FILE=new-index git read-tree main
'
test_done

View File

@ -2,7 +2,7 @@
test_description='sparse checkout tests
* (tag: removed, master) removed
* (tag: removed, main) removed
| D sub/added
* (HEAD, tag: top) modified and added
| M init.t

View File

@ -1,6 +1,9 @@
#!/bin/sh
test_description='rerere run in a workdir'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success SYMLINKS setup '
@ -19,7 +22,7 @@ test_expect_success SYMLINKS setup '
test_tick &&
git commit -a -m goodbye &&
git checkout master
git checkout main
'
test_expect_success SYMLINKS 'rerere in workdir' '

View File

@ -2,6 +2,9 @@
test_description='sparse checkout scope tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'setup' '
@ -20,18 +23,18 @@ test_expect_success 'create feature branch' '
git commit -m "modification"
'
test_expect_success 'perform sparse checkout of master' '
test_expect_success 'perform sparse checkout of main' '
git config --local --bool core.sparsecheckout true &&
echo "!/*" >.git/info/sparse-checkout &&
echo "/a" >>.git/info/sparse-checkout &&
echo "/c" >>.git/info/sparse-checkout &&
git checkout master &&
git checkout main &&
test_path_is_file a &&
test_path_is_missing b &&
test_path_is_file c
'
test_expect_success 'merge feature branch into sparse checkout of master' '
test_expect_success 'merge feature branch into sparse checkout of main' '
git merge feature &&
test_path_is_file a &&
test_path_is_missing b &&
@ -39,10 +42,10 @@ test_expect_success 'merge feature branch into sparse checkout of master' '
test "$(cat c)" = "modified"
'
test_expect_success 'return to full checkout of master' '
test_expect_success 'return to full checkout of main' '
git checkout feature &&
echo "/*" >.git/info/sparse-checkout &&
git checkout master &&
git checkout main &&
test_path_is_file a &&
test_path_is_file b &&
test_path_is_file c &&

View File

@ -2,6 +2,9 @@
test_description='sparse checkout builtin tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
list_files() {
@ -117,7 +120,7 @@ test_expect_success 'interaction with clone --no-checkout (unborn index)' '
test_path_is_missing clone_no_checkout/.git/index &&
# No branch is checked out until we manually switch to one
git -C clone_no_checkout switch master &&
git -C clone_no_checkout switch main &&
test_path_is_file clone_no_checkout/.git/index &&
check_files clone_no_checkout a folder1
'

View File

@ -5,6 +5,9 @@
test_description='Test git config in different settings'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'clear default config' '
@ -1046,8 +1049,8 @@ test_expect_success 'check split_cmdline return' "
echo foo > foo &&
git add foo &&
git commit -m 'initial commit' &&
git config branch.master.mergeoptions 'echo \"' &&
test_must_fail git merge master
git config branch.main.mergeoptions 'echo \"' &&
test_must_fail git merge main
"
test_expect_success 'git -c "key=value" support' '
@ -1761,11 +1764,11 @@ test_expect_success '--show-origin blob' '
test_expect_success '--show-origin blob ref' '
cat >expect <<-\EOF &&
blob:master:custom.conf user.custom=true
blob:main:custom.conf user.custom=true
EOF
git add "$CUSTOM_CONFIG_FILE" &&
git commit -m "new config file" &&
git config --blob=master:"$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
git config --blob=main:"$CUSTOM_CONFIG_FILE" --show-origin --list >output &&
test_cmp expect output
'

View File

@ -5,6 +5,9 @@
test_description='Test shared repository initialization'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
# Remove a default ACL from the test dir if possible.
@ -115,13 +118,13 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
umask 077 &&
git config core.sharedRepository group &&
git reflog expire --all &&
actual="$(ls -l .git/logs/refs/heads/master)" &&
actual="$(ls -l .git/logs/refs/heads/main)" &&
case "$actual" in
-rw-rw-*)
: happy
;;
*)
echo Ooops, .git/logs/refs/heads/master is not 0662 [$actual]
echo Ooops, .git/logs/refs/heads/main is not 0662 [$actual]
false
;;
esac

View File

@ -312,7 +312,7 @@ test_expect_success SYMLINKS 'conditional include, gitdir matching symlink, icas
test_expect_success 'conditional include, onbranch' '
echo "[includeIf \"onbranch:foo-branch\"]path=bar9" >>.git/config &&
echo "[test]nine=9" >.git/bar9 &&
git checkout -b master &&
git checkout -b main &&
test_must_fail git config test.nine &&
git checkout -b foo-branch &&
echo 9 >expect &&

View File

@ -4,6 +4,9 @@
#
test_description='Test git update-ref and basic ref logging'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
Z=$ZERO_OID

View File

@ -134,18 +134,18 @@ valid_ref !MINGW "$ref" '--refspec-pattern --allow-onelevel --normalize'
test_expect_success "check-ref-format --branch @{-1}" '
T=$(git write-tree) &&
sha1=$(echo A | git commit-tree $T) &&
git update-ref refs/heads/master $sha1 &&
git update-ref refs/remotes/origin/master $sha1 &&
git checkout master &&
git checkout origin/master &&
git checkout master &&
git update-ref refs/heads/main $sha1 &&
git update-ref refs/remotes/origin/main $sha1 &&
git checkout main &&
git checkout origin/main &&
git checkout main &&
refname=$(git check-ref-format --branch @{-1}) &&
test "$refname" = "$sha1" &&
refname2=$(git check-ref-format --branch @{-2}) &&
test "$refname2" = master'
test "$refname2" = main'
test_expect_success 'check-ref-format --branch -naster' '
test_must_fail git check-ref-format --branch -naster >actual &&
test_expect_success 'check-ref-format --branch -nain' '
test_must_fail git check-ref-format --branch -nain >actual &&
test_must_be_empty actual
'
@ -154,11 +154,11 @@ test_expect_success 'check-ref-format --branch from subdir' '
T=$(git write-tree) &&
sha1=$(echo A | git commit-tree $T) &&
git update-ref refs/heads/master $sha1 &&
git update-ref refs/remotes/origin/master $sha1 &&
git checkout master &&
git checkout origin/master &&
git checkout master &&
git update-ref refs/heads/main $sha1 &&
git update-ref refs/remotes/origin/main $sha1 &&
git checkout main &&
git checkout origin/main &&
git checkout main &&
refname=$(
cd subdir &&
git check-ref-format --branch @{-1}
@ -171,9 +171,9 @@ test_expect_success 'check-ref-format --branch @{-1} from non-repo' '
test_must_be_empty actual
'
test_expect_success 'check-ref-format --branch master from non-repo' '
echo master >expect &&
nongit git check-ref-format --branch master >actual &&
test_expect_success 'check-ref-format --branch main from non-repo' '
echo main >expect &&
nongit git check-ref-format --branch main >actual &&
test_cmp expect actual
'

View File

@ -1,6 +1,9 @@
#!/bin/sh
test_description='show-ref'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '
@ -9,7 +12,7 @@ test_expect_success setup '
git checkout -b side &&
test_commit B &&
git tag -f -a -m "annotated B" B &&
git checkout master &&
git checkout main &&
test_commit C &&
git branch B A^0
'
@ -92,23 +95,23 @@ test_expect_success 'show-ref -d' '
git show-ref --verify -d refs/tags/A refs/tags/C >actual &&
test_cmp expect actual &&
echo $(git rev-parse refs/heads/master) refs/heads/master >expect &&
git show-ref -d master >actual &&
echo $(git rev-parse refs/heads/main) refs/heads/main >expect &&
git show-ref -d main >actual &&
test_cmp expect actual &&
git show-ref -d heads/master >actual &&
git show-ref -d heads/main >actual &&
test_cmp expect actual &&
git show-ref -d refs/heads/master >actual &&
git show-ref -d refs/heads/main >actual &&
test_cmp expect actual &&
git show-ref -d --verify refs/heads/master >actual &&
git show-ref -d --verify refs/heads/main >actual &&
test_cmp expect actual &&
test_must_fail git show-ref -d --verify master >actual &&
test_must_fail git show-ref -d --verify main >actual &&
test_must_be_empty actual &&
test_must_fail git show-ref -d --verify heads/master >actual &&
test_must_fail git show-ref -d --verify heads/main >actual &&
test_must_be_empty actual &&
test_must_fail git show-ref --verify -d A C >actual &&
@ -120,7 +123,7 @@ test_expect_success 'show-ref -d' '
'
test_expect_success 'show-ref --heads, --tags, --head, pattern' '
for branch in B master side
for branch in B main side
do
echo $(git rev-parse refs/heads/$branch) refs/heads/$branch
done >expect.heads &&

View File

@ -2,6 +2,9 @@
test_description='test main ref store api'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
RUN="test-tool ref-store main"
@ -21,9 +24,9 @@ test_expect_success 'peel_ref(new-tag)' '
test_cmp expected actual
'
test_expect_success 'create_symref(FOO, refs/heads/master)' '
$RUN create-symref FOO refs/heads/master nothing &&
echo refs/heads/master >expected &&
test_expect_success 'create_symref(FOO, refs/heads/main)' '
$RUN create-symref FOO refs/heads/main nothing &&
echo refs/heads/main >expected &&
git symbolic-ref FOO >actual &&
test_cmp expected actual
'
@ -31,7 +34,7 @@ test_expect_success 'create_symref(FOO, refs/heads/master)' '
test_expect_success 'delete_refs(FOO, refs/tags/new-tag)' '
git rev-parse FOO -- &&
git rev-parse refs/tags/new-tag -- &&
m=$(git rev-parse master) &&
m=$(git rev-parse main) &&
REF_NO_DEREF=1 &&
$RUN delete-refs $REF_NO_DEREF nothing FOO refs/tags/new-tag &&
test_must_fail git rev-parse --symbolic-full-name FOO &&
@ -39,19 +42,19 @@ test_expect_success 'delete_refs(FOO, refs/tags/new-tag)' '
test_must_fail git rev-parse refs/tags/new-tag --
'
test_expect_success 'rename_refs(master, new-master)' '
git rev-parse master >expected &&
$RUN rename-ref refs/heads/master refs/heads/new-master &&
git rev-parse new-master >actual &&
test_expect_success 'rename_refs(main, new-main)' '
git rev-parse main >expected &&
$RUN rename-ref refs/heads/main refs/heads/new-main &&
git rev-parse new-main >actual &&
test_cmp expected actual &&
test_commit recreate-master
test_commit recreate-main
'
test_expect_success 'for_each_ref(refs/heads/)' '
$RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
cat >expected <<-\EOF &&
master 0x0
new-master 0x0
main 0x0
new-main 0x0
EOF
test_cmp expected actual
'
@ -62,23 +65,23 @@ test_expect_success 'for_each_ref() is sorted' '
test_cmp expected actual
'
test_expect_success 'resolve_ref(new-master)' '
SHA1=`git rev-parse new-master` &&
echo "$SHA1 refs/heads/new-master 0x0" >expected &&
$RUN resolve-ref refs/heads/new-master 0 >actual &&
test_expect_success 'resolve_ref(new-main)' '
SHA1=`git rev-parse new-main` &&
echo "$SHA1 refs/heads/new-main 0x0" >expected &&
$RUN resolve-ref refs/heads/new-main 0 >actual &&
test_cmp expected actual
'
test_expect_success 'verify_ref(new-master)' '
$RUN verify-ref refs/heads/new-master
test_expect_success 'verify_ref(new-main)' '
$RUN verify-ref refs/heads/new-main
'
test_expect_success 'for_each_reflog()' '
$RUN for-each-reflog | sort -k2 | cut -d" " -f 2- >actual &&
cat >expected <<-\EOF &&
HEAD 0x1
refs/heads/master 0x0
refs/heads/new-master 0x0
refs/heads/main 0x0
refs/heads/new-main 0x0
EOF
test_cmp expected actual
'
@ -86,12 +89,12 @@ test_expect_success 'for_each_reflog()' '
test_expect_success 'for_each_reflog_ent()' '
$RUN for-each-reflog-ent HEAD >actual &&
head -n1 actual | grep one &&
tail -n2 actual | head -n1 | grep recreate-master
tail -n2 actual | head -n1 | grep recreate-main
'
test_expect_success 'for_each_reflog_ent_reverse()' '
$RUN for-each-reflog-ent-reverse HEAD >actual &&
head -n1 actual | grep recreate-master &&
head -n1 actual | grep recreate-main &&
tail -n2 actual | head -n1 | grep one
'

View File

@ -2,6 +2,9 @@
test_description='test submodule ref store api'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
RUN="test-tool ref-store submodule:sub"
@ -11,7 +14,7 @@ test_expect_success 'setup' '
(
cd sub &&
test_commit first &&
git checkout -b new-master
git checkout -b new-main
)
'
@ -27,7 +30,7 @@ test_expect_success 'peel_ref(new-tag)' '
'
test_expect_success 'create_symref() not allowed' '
test_must_fail $RUN create-symref FOO refs/heads/master nothing
test_must_fail $RUN create-symref FOO refs/heads/main nothing
'
test_expect_success 'delete_refs() not allowed' '
@ -35,14 +38,14 @@ test_expect_success 'delete_refs() not allowed' '
'
test_expect_success 'rename_refs() not allowed' '
test_must_fail $RUN rename-ref refs/heads/master refs/heads/new-master
test_must_fail $RUN rename-ref refs/heads/main refs/heads/new-main
'
test_expect_success 'for_each_ref(refs/heads/)' '
$RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
cat >expected <<-\EOF &&
master 0x0
new-master 0x0
main 0x0
new-main 0x0
EOF
test_cmp expected actual
'
@ -53,23 +56,23 @@ test_expect_success 'for_each_ref() is sorted' '
test_cmp expected actual
'
test_expect_success 'resolve_ref(master)' '
SHA1=`git -C sub rev-parse master` &&
echo "$SHA1 refs/heads/master 0x0" >expected &&
$RUN resolve-ref refs/heads/master 0 >actual &&
test_expect_success 'resolve_ref(main)' '
SHA1=`git -C sub rev-parse main` &&
echo "$SHA1 refs/heads/main 0x0" >expected &&
$RUN resolve-ref refs/heads/main 0 >actual &&
test_cmp expected actual
'
test_expect_success 'verify_ref(new-master)' '
$RUN verify-ref refs/heads/new-master
test_expect_success 'verify_ref(new-main)' '
$RUN verify-ref refs/heads/new-main
'
test_expect_success 'for_each_reflog()' '
$RUN for-each-reflog | sort | cut -d" " -f 2- >actual &&
cat >expected <<-\EOF &&
HEAD 0x1
refs/heads/master 0x0
refs/heads/new-master 0x0
refs/heads/main 0x0
refs/heads/new-main 0x0
EOF
test_cmp expected actual
'
@ -77,12 +80,12 @@ test_expect_success 'for_each_reflog()' '
test_expect_success 'for_each_reflog_ent()' '
$RUN for-each-reflog-ent HEAD >actual &&
head -n1 actual | grep first &&
tail -n2 actual | head -n1 | grep master.to.new
tail -n2 actual | head -n1 | grep main.to.new
'
test_expect_success 'for_each_reflog_ent_reverse()' '
$RUN for-each-reflog-ent-reverse HEAD >actual &&
head -n1 actual | grep master.to.new &&
head -n1 actual | grep main.to.new &&
tail -n2 actual | head -n1 | grep first
'

View File

@ -2,6 +2,9 @@
test_description='test worktree ref store api'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
RWT="test-tool ref-store worktree:wt"
@ -9,7 +12,7 @@ RMAIN="test-tool ref-store worktree:main"
test_expect_success 'setup' '
test_commit first &&
git worktree add -b wt-master wt &&
git worktree add -b wt-main wt &&
(
cd wt &&
test_commit second
@ -17,34 +20,34 @@ test_expect_success 'setup' '
'
test_expect_success 'resolve_ref(<shared-ref>)' '
SHA1=`git rev-parse master` &&
echo "$SHA1 refs/heads/master 0x0" >expected &&
$RWT resolve-ref refs/heads/master 0 >actual &&
SHA1=`git rev-parse main` &&
echo "$SHA1 refs/heads/main 0x0" >expected &&
$RWT resolve-ref refs/heads/main 0 >actual &&
test_cmp expected actual &&
$RMAIN resolve-ref refs/heads/master 0 >actual &&
$RMAIN resolve-ref refs/heads/main 0 >actual &&
test_cmp expected actual
'
test_expect_success 'resolve_ref(<per-worktree-ref>)' '
SHA1=`git -C wt rev-parse HEAD` &&
echo "$SHA1 refs/heads/wt-master 0x1" >expected &&
echo "$SHA1 refs/heads/wt-main 0x1" >expected &&
$RWT resolve-ref HEAD 0 >actual &&
test_cmp expected actual &&
SHA1=`git rev-parse HEAD` &&
echo "$SHA1 refs/heads/master 0x1" >expected &&
echo "$SHA1 refs/heads/main 0x1" >expected &&
$RMAIN resolve-ref HEAD 0 >actual &&
test_cmp expected actual
'
test_expect_success 'create_symref(FOO, refs/heads/master)' '
$RWT create-symref FOO refs/heads/master nothing &&
echo refs/heads/master >expected &&
test_expect_success 'create_symref(FOO, refs/heads/main)' '
$RWT create-symref FOO refs/heads/main nothing &&
echo refs/heads/main >expected &&
git -C wt symbolic-ref FOO >actual &&
test_cmp expected actual &&
$RMAIN create-symref FOO refs/heads/wt-master nothing &&
echo refs/heads/wt-master >expected &&
$RMAIN create-symref FOO refs/heads/wt-main nothing &&
echo refs/heads/wt-main >expected &&
git symbolic-ref FOO >actual &&
test_cmp expected actual
'
@ -63,8 +66,8 @@ test_expect_success 'for_each_reflog()' '
HEAD 0x1
PSEUDO-WT 0x0
refs/bisect/wt-random 0x0
refs/heads/master 0x0
refs/heads/wt-master 0x0
refs/heads/main 0x0
refs/heads/wt-main 0x0
EOF
test_cmp expected actual &&
@ -73,8 +76,8 @@ test_expect_success 'for_each_reflog()' '
HEAD 0x1
PSEUDO-MAIN 0x0
refs/bisect/random 0x0
refs/heads/master 0x0
refs/heads/wt-master 0x0
refs/heads/main 0x0
refs/heads/wt-main 0x0
EOF
test_cmp expected actual
'

View File

@ -2,6 +2,9 @@
test_description='packed-refs entries are covered by loose refs'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '
@ -9,32 +12,32 @@ test_expect_success setup '
git commit --allow-empty -m one &&
one=$(git rev-parse HEAD) &&
git for-each-ref >actual &&
echo "$one commit refs/heads/master" >expect &&
echo "$one commit refs/heads/main" >expect &&
test_cmp expect actual &&
git pack-refs --all &&
git for-each-ref >actual &&
echo "$one commit refs/heads/master" >expect &&
echo "$one commit refs/heads/main" >expect &&
test_cmp expect actual &&
git checkout --orphan another &&
test_tick &&
git commit --allow-empty -m two &&
two=$(git rev-parse HEAD) &&
git checkout -B master &&
git checkout -B main &&
git branch -D another &&
git for-each-ref >actual &&
echo "$two commit refs/heads/master" >expect &&
echo "$two commit refs/heads/main" >expect &&
test_cmp expect actual &&
git reflog expire --expire=now --all &&
git prune &&
git tag -m v1.0 v1.0 master
git tag -m v1.0 v1.0 main
'
test_expect_success 'no error from stale entry in packed-refs' '
git describe master >actual 2>&1 &&
git describe main >actual 2>&1 &&
echo "v1.0" >expect &&
test_cmp expect actual
'

View File

@ -4,6 +4,9 @@
#
test_description='Test prune and reflog expiration'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
check_have () {
@ -99,7 +102,7 @@ test_expect_success setup '
check_fsck &&
git reflog refs/heads/master >output &&
git reflog refs/heads/main >output &&
test_line_count = 4 output
'
@ -116,7 +119,7 @@ test_expect_success rewind '
check_have A B C D E F G H I J K L &&
git reflog refs/heads/master >output &&
git reflog refs/heads/main >output &&
test_line_count = 5 output
'
@ -135,7 +138,7 @@ test_expect_success 'reflog expire --dry-run should not touch reflog' '
--stale-fix \
--all &&
git reflog refs/heads/master >output &&
git reflog refs/heads/main >output &&
test_line_count = 5 output &&
check_fsck "missing blob $F"
@ -149,7 +152,7 @@ test_expect_success 'reflog expire' '
--stale-fix \
--all &&
git reflog refs/heads/master >output &&
git reflog refs/heads/main >output &&
test_line_count = 2 output &&
check_fsck "dangling commit $K"
@ -186,29 +189,29 @@ test_expect_success 'delete' '
git commit -m tiger C &&
HEAD_entry_count=$(git reflog | wc -l) &&
master_entry_count=$(git reflog show master | wc -l) &&
main_entry_count=$(git reflog show main | wc -l) &&
test $HEAD_entry_count = 5 &&
test $master_entry_count = 5 &&
test $main_entry_count = 5 &&
git reflog delete master@{1} &&
git reflog show master > output &&
test_line_count = $(($master_entry_count - 1)) output &&
git reflog delete main@{1} &&
git reflog show main > output &&
test_line_count = $(($main_entry_count - 1)) output &&
test $HEAD_entry_count = $(git reflog | wc -l) &&
! grep ox < output &&
master_entry_count=$(wc -l < output) &&
main_entry_count=$(wc -l < output) &&
git reflog delete HEAD@{1} &&
test $(($HEAD_entry_count -1)) = $(git reflog | wc -l) &&
test $master_entry_count = $(git reflog show master | wc -l) &&
test $main_entry_count = $(git reflog show main | wc -l) &&
HEAD_entry_count=$(git reflog | wc -l) &&
git reflog delete master@{07.04.2005.15:15:00.-0700} &&
git reflog show master > output &&
test_line_count = $(($master_entry_count - 1)) output &&
git reflog delete main@{07.04.2005.15:15:00.-0700} &&
git reflog show main > output &&
test_line_count = $(($main_entry_count - 1)) output &&
! grep dragon < output
'
@ -216,7 +219,7 @@ test_expect_success 'delete' '
test_expect_success 'rewind2' '
test_tick && git reset --hard HEAD~2 &&
git reflog refs/heads/master >output &&
git reflog refs/heads/main >output &&
test_line_count = 4 output
'
@ -226,7 +229,7 @@ test_expect_success '--expire=never' '
--expire=never \
--expire-unreachable=never \
--all &&
git reflog refs/heads/master >output &&
git reflog refs/heads/main >output &&
test_line_count = 4 output
'
@ -237,7 +240,7 @@ test_expect_success 'gc.reflogexpire=never' '
git reflog expire --verbose --all >output &&
test_line_count = 9 output &&
git reflog refs/heads/master >output &&
git reflog refs/heads/main >output &&
test_line_count = 4 output
'
@ -246,7 +249,7 @@ test_expect_success 'gc.reflogexpire=false' '
test_config gc.reflogexpireunreachable false &&
git reflog expire --verbose --all &&
git reflog refs/heads/master >output &&
git reflog refs/heads/main >output &&
test_line_count = 4 output
'
@ -255,33 +258,33 @@ test_expect_success 'git reflog expire unknown reference' '
test_config gc.reflogexpire never &&
test_config gc.reflogexpireunreachable never &&
test_must_fail git reflog expire master@{123} 2>stderr &&
test_must_fail git reflog expire main@{123} 2>stderr &&
test_i18ngrep "points nowhere" stderr &&
test_must_fail git reflog expire does-not-exist 2>stderr &&
test_i18ngrep "points nowhere" stderr
'
test_expect_success 'checkout should not delete log for packed ref' '
test $(git reflog master | wc -l) = 4 &&
test $(git reflog main | wc -l) = 4 &&
git branch foo &&
git pack-refs --all &&
git checkout foo &&
test $(git reflog master | wc -l) = 4
test $(git reflog main | wc -l) = 4
'
test_expect_success 'stale dirs do not cause d/f conflicts (reflogs on)' '
test_when_finished "git branch -d one || git branch -d one/two" &&
git branch one/two master &&
echo "one/two@{0} branch: Created from master" >expect &&
git branch one/two main &&
echo "one/two@{0} branch: Created from main" >expect &&
git log -g --format="%gd %gs" one/two >actual &&
test_cmp expect actual &&
git branch -d one/two &&
# now logs/refs/heads/one is a stale directory, but
# we should move it out of the way to create "one" reflog
git branch one master &&
echo "one@{0} branch: Created from master" >expect &&
git branch one main &&
echo "one@{0} branch: Created from main" >expect &&
git log -g --format="%gd %gs" one >actual &&
test_cmp expect actual
'
@ -289,15 +292,15 @@ test_expect_success 'stale dirs do not cause d/f conflicts (reflogs on)' '
test_expect_success 'stale dirs do not cause d/f conflicts (reflogs off)' '
test_when_finished "git branch -d one || git branch -d one/two" &&
git branch one/two master &&
echo "one/two@{0} branch: Created from master" >expect &&
git branch one/two main &&
echo "one/two@{0} branch: Created from main" >expect &&
git log -g --format="%gd %gs" one/two >actual &&
test_cmp expect actual &&
git branch -d one/two &&
# same as before, but we only create a reflog for "one" if
# it already exists, which it does not
git -c core.logallrefupdates=false branch one master &&
git -c core.logallrefupdates=false branch one main &&
git log -g --format="%gd %gs" one >actual &&
test_must_be_empty actual
'

View File

@ -1,6 +1,9 @@
#!/bin/sh
test_description='Test reflog display routines'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'setup' '
@ -167,7 +170,7 @@ test_expect_success 'git log -g -p shows diffs vs. parents' '
'
test_expect_success 'reflog exists works' '
git reflog exists refs/heads/master &&
git reflog exists refs/heads/main &&
! git reflog exists refs/heads/nonexistent
'

View File

@ -1,10 +1,13 @@
#!/bin/sh
test_description='Test reflog interaction with detached HEAD'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
reset_state () {
git checkout master &&
git checkout main &&
cp saved_reflog .git/logs/HEAD
}
@ -19,14 +22,14 @@ test_expect_success setup '
test_expect_success baseline '
reset_state &&
git rev-parse master master^ >expect &&
git rev-parse main main^ >expect &&
git log -g --format=%H >actual &&
test_cmp expect actual
'
test_expect_success 'switch to branch' '
reset_state &&
git rev-parse side master master^ >expect &&
git rev-parse side main main^ >expect &&
git checkout side &&
git log -g --format=%H >actual &&
test_cmp expect actual
@ -34,34 +37,34 @@ test_expect_success 'switch to branch' '
test_expect_success 'detach to other' '
reset_state &&
git rev-parse master side master master^ >expect &&
git rev-parse main side main main^ >expect &&
git checkout side &&
git checkout master^0 &&
git checkout main^0 &&
git log -g --format=%H >actual &&
test_cmp expect actual
'
test_expect_success 'detach to self' '
reset_state &&
git rev-parse master master master^ >expect &&
git checkout master^0 &&
git rev-parse main main main^ >expect &&
git checkout main^0 &&
git log -g --format=%H >actual &&
test_cmp expect actual
'
test_expect_success 'attach to self' '
reset_state &&
git rev-parse master master master master^ >expect &&
git checkout master^0 &&
git checkout master &&
git rev-parse main main main main^ >expect &&
git checkout main^0 &&
git checkout main &&
git log -g --format=%H >actual &&
test_cmp expect actual
'
test_expect_success 'attach to other' '
reset_state &&
git rev-parse side master master master^ >expect &&
git checkout master^0 &&
git rev-parse side main main main^ >expect &&
git checkout main^0 &&
git checkout side &&
git log -g --format=%H >actual &&
test_cmp expect actual

View File

@ -1,6 +1,9 @@
#!/bin/sh
test_description='various tests of reflog walk (log -g) behavior'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'set up some reflog entries' '
@ -8,7 +11,7 @@ test_expect_success 'set up some reflog entries' '
test_commit two &&
git checkout -b side HEAD^ &&
test_commit three &&
git merge --no-commit master &&
git merge --no-commit main &&
echo evil-merge-content >>one.t &&
test_tick &&
git commit --no-edit -a
@ -20,9 +23,9 @@ do_walk () {
test_expect_success 'set up expected reflog' '
cat >expect.all <<-EOF
HEAD@{0} commit (merge): Merge branch ${SQ}master${SQ} into side
HEAD@{0} commit (merge): Merge branch ${SQ}main${SQ} into side
HEAD@{1} commit: three
HEAD@{2} checkout: moving from master to side
HEAD@{2} checkout: moving from main to side
HEAD@{3} commit: two
HEAD@{4} commit (initial): one
EOF
@ -73,15 +76,15 @@ test_expect_success 'walking multiple reflogs shows all' '
# sort ignores the bits after the timestamp.
#
# 2. POSIX leaves undefined whether this is a stable sort or not. So
# we use "-k 1" to ensure that we see HEAD before master before
# we use "-k 1" to ensure that we see HEAD before main before
# side when breaking ties.
{
do_walk --date=unix HEAD &&
do_walk --date=unix side &&
do_walk --date=unix master
do_walk --date=unix main
} >expect.raw &&
sort -t "{" -k 2nr -k 1 <expect.raw >expect &&
do_walk --date=unix HEAD master side >actual &&
do_walk --date=unix HEAD main side >actual &&
test_cmp expect actual
'

View File

@ -2,6 +2,9 @@
test_description='reference transaction hooks'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '
@ -53,11 +56,11 @@ test_expect_success 'hook gets all queued updates in prepared state' '
EOF
cat >expect <<-EOF &&
$ZERO_OID $POST_OID HEAD
$ZERO_OID $POST_OID refs/heads/master
$ZERO_OID $POST_OID refs/heads/main
EOF
git update-ref HEAD POST <<-EOF &&
update HEAD $ZERO_OID $POST_OID
update refs/heads/master $ZERO_OID $POST_OID
update refs/heads/main $ZERO_OID $POST_OID
EOF
test_cmp expect actual
'
@ -76,7 +79,7 @@ test_expect_success 'hook gets all queued updates in committed state' '
EOF
cat >expect <<-EOF &&
$ZERO_OID $POST_OID HEAD
$ZERO_OID $POST_OID refs/heads/master
$ZERO_OID $POST_OID refs/heads/main
EOF
git update-ref HEAD POST &&
test_cmp expect actual
@ -96,12 +99,12 @@ test_expect_success 'hook gets all queued updates in aborted state' '
EOF
cat >expect <<-EOF &&
$ZERO_OID $POST_OID HEAD
$ZERO_OID $POST_OID refs/heads/master
$ZERO_OID $POST_OID refs/heads/main
EOF
git update-ref --stdin <<-EOF &&
start
update HEAD POST $ZERO_OID
update refs/heads/master POST $ZERO_OID
update refs/heads/main POST $ZERO_OID
abort
EOF
test_cmp expect actual

View File

@ -1,6 +1,9 @@
#!/bin/sh
test_description='Test handling of ref names that check-ref-format rejects'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '
@ -17,7 +20,7 @@ test_expect_success 'fast-import: fail on invalid branch name ".badbranchname"'
corrupt
COMMIT
from refs/heads/master
from refs/heads/main
INPUT_END
test_must_fail git fast-import <input
@ -32,14 +35,14 @@ test_expect_success 'fast-import: fail on invalid branch name "bad[branch]name"'
corrupt
COMMIT
from refs/heads/master
from refs/heads/main
INPUT_END
test_must_fail git fast-import <input
'
test_expect_success 'git branch shows badly named ref as warning' '
cp .git/refs/heads/master .git/refs/heads/broken...ref &&
cp .git/refs/heads/main .git/refs/heads/broken...ref &&
test_when_finished "rm -f .git/refs/heads/broken...ref" &&
git branch >output 2>error &&
test_i18ngrep -e "ignoring ref with broken name refs/heads/broken\.\.\.ref" error &&
@ -47,7 +50,7 @@ test_expect_success 'git branch shows badly named ref as warning' '
'
test_expect_success 'branch -d can delete badly named ref' '
cp .git/refs/heads/master .git/refs/heads/broken...ref &&
cp .git/refs/heads/main .git/refs/heads/broken...ref &&
test_when_finished "rm -f .git/refs/heads/broken...ref" &&
git branch -d broken...ref &&
git branch >output 2>error &&
@ -56,7 +59,7 @@ test_expect_success 'branch -d can delete badly named ref' '
'
test_expect_success 'branch -D can delete badly named ref' '
cp .git/refs/heads/master .git/refs/heads/broken...ref &&
cp .git/refs/heads/main .git/refs/heads/broken...ref &&
test_when_finished "rm -f .git/refs/heads/broken...ref" &&
git branch -D broken...ref &&
git branch >output 2>error &&
@ -98,17 +101,17 @@ test_expect_success 'branch -m cannot rename to a bad ref name' '
test_might_fail git branch -D goodref &&
git branch goodref &&
test_must_fail git branch -m goodref broken...ref &&
test_cmp_rev master goodref &&
test_cmp_rev main goodref &&
git branch >output 2>error &&
! grep -e "broken\.\.\.ref" error &&
! grep -e "broken\.\.\.ref" output
'
test_expect_failure 'branch -m can rename from a bad ref name' '
cp .git/refs/heads/master .git/refs/heads/broken...ref &&
cp .git/refs/heads/main .git/refs/heads/broken...ref &&
test_when_finished "rm -f .git/refs/heads/broken...ref" &&
git branch -m broken...ref renamed &&
test_cmp_rev master renamed &&
test_cmp_rev main renamed &&
git branch >output 2>error &&
! grep -e "broken\.\.\.ref" error &&
! grep -e "broken\.\.\.ref" output
@ -135,7 +138,7 @@ test_expect_failure C_LOCALE_OUTPUT 'push --mirror can delete badly named ref' '
cd dest &&
test_commit two &&
git checkout --detach &&
cp .git/refs/heads/master .git/refs/heads/broken...ref
cp .git/refs/heads/main .git/refs/heads/broken...ref
) &&
git -C src push --mirror "file://$top/dest" &&
git -C dest branch >output 2>error &&
@ -146,7 +149,7 @@ test_expect_failure C_LOCALE_OUTPUT 'push --mirror can delete badly named ref' '
test_expect_success 'rev-parse skips symref pointing to broken name' '
test_when_finished "rm -f .git/refs/heads/broken...ref" &&
git branch shadow one &&
cp .git/refs/heads/master .git/refs/heads/broken...ref &&
cp .git/refs/heads/main .git/refs/heads/broken...ref &&
printf "ref: refs/heads/broken...ref\n" >.git/refs/tags/shadow &&
test_when_finished "rm -f .git/refs/tags/shadow" &&
git rev-parse --verify one >expect &&
@ -156,11 +159,11 @@ test_expect_success 'rev-parse skips symref pointing to broken name' '
'
test_expect_success 'for-each-ref emits warnings for broken names' '
cp .git/refs/heads/master .git/refs/heads/broken...ref &&
cp .git/refs/heads/main .git/refs/heads/broken...ref &&
test_when_finished "rm -f .git/refs/heads/broken...ref" &&
printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname &&
test_when_finished "rm -f .git/refs/heads/badname" &&
printf "ref: refs/heads/master\n" >.git/refs/heads/broken...symref &&
printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref &&
test_when_finished "rm -f .git/refs/heads/broken...symref" &&
git for-each-ref >output 2>error &&
! grep -e "broken\.\.\.ref" output &&
@ -172,7 +175,7 @@ test_expect_success 'for-each-ref emits warnings for broken names' '
'
test_expect_success 'update-ref -d can delete broken name' '
cp .git/refs/heads/master .git/refs/heads/broken...ref &&
cp .git/refs/heads/main .git/refs/heads/broken...ref &&
test_when_finished "rm -f .git/refs/heads/broken...ref" &&
git update-ref -d refs/heads/broken...ref >output 2>error &&
test_must_be_empty output &&
@ -183,7 +186,7 @@ test_expect_success 'update-ref -d can delete broken name' '
'
test_expect_success 'branch -d can delete broken name' '
cp .git/refs/heads/master .git/refs/heads/broken...ref &&
cp .git/refs/heads/main .git/refs/heads/broken...ref &&
test_when_finished "rm -f .git/refs/heads/broken...ref" &&
git branch -d broken...ref >output 2>error &&
test_i18ngrep "Deleted branch broken...ref (was broken)" output &&
@ -194,7 +197,7 @@ test_expect_success 'branch -d can delete broken name' '
'
test_expect_success 'update-ref --no-deref -d can delete symref to broken name' '
cp .git/refs/heads/master .git/refs/heads/broken...ref &&
cp .git/refs/heads/main .git/refs/heads/broken...ref &&
test_when_finished "rm -f .git/refs/heads/broken...ref" &&
printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname &&
test_when_finished "rm -f .git/refs/heads/badname" &&
@ -205,7 +208,7 @@ test_expect_success 'update-ref --no-deref -d can delete symref to broken name'
'
test_expect_success 'branch -d can delete symref to broken name' '
cp .git/refs/heads/master .git/refs/heads/broken...ref &&
cp .git/refs/heads/main .git/refs/heads/broken...ref &&
test_when_finished "rm -f .git/refs/heads/broken...ref" &&
printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname &&
test_when_finished "rm -f .git/refs/heads/badname" &&
@ -234,7 +237,7 @@ test_expect_success 'branch -d can delete dangling symref to broken name' '
'
test_expect_success 'update-ref -d can delete broken name through symref' '
cp .git/refs/heads/master .git/refs/heads/broken...ref &&
cp .git/refs/heads/main .git/refs/heads/broken...ref &&
test_when_finished "rm -f .git/refs/heads/broken...ref" &&
printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname &&
test_when_finished "rm -f .git/refs/heads/badname" &&
@ -245,7 +248,7 @@ test_expect_success 'update-ref -d can delete broken name through symref' '
'
test_expect_success 'update-ref --no-deref -d can delete symref with broken name' '
printf "ref: refs/heads/master\n" >.git/refs/heads/broken...symref &&
printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref &&
test_when_finished "rm -f .git/refs/heads/broken...symref" &&
git update-ref --no-deref -d refs/heads/broken...symref >output 2>error &&
test_path_is_missing .git/refs/heads/broken...symref &&
@ -254,11 +257,11 @@ test_expect_success 'update-ref --no-deref -d can delete symref with broken name
'
test_expect_success 'branch -d can delete symref with broken name' '
printf "ref: refs/heads/master\n" >.git/refs/heads/broken...symref &&
printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref &&
test_when_finished "rm -f .git/refs/heads/broken...symref" &&
git branch -d broken...symref >output 2>error &&
test_path_is_missing .git/refs/heads/broken...symref &&
test_i18ngrep "Deleted branch broken...symref (was refs/heads/master)" output &&
test_i18ngrep "Deleted branch broken...symref (was refs/heads/main)" output &&
test_must_be_empty error
'
@ -296,37 +299,37 @@ test_expect_success 'update-ref -d cannot delete absolute path' '
'
test_expect_success 'update-ref --stdin fails create with bad ref name' '
echo "create ~a refs/heads/master" >stdin &&
echo "create ~a refs/heads/main" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
grep "fatal: invalid ref format: ~a" err
'
test_expect_success 'update-ref --stdin fails update with bad ref name' '
echo "update ~a refs/heads/master" >stdin &&
echo "update ~a refs/heads/main" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
grep "fatal: invalid ref format: ~a" err
'
test_expect_success 'update-ref --stdin fails delete with bad ref name' '
echo "delete ~a refs/heads/master" >stdin &&
echo "delete ~a refs/heads/main" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
grep "fatal: invalid ref format: ~a" err
'
test_expect_success 'update-ref --stdin -z fails create with bad ref name' '
printf "%s\0" "create ~a " refs/heads/master >stdin &&
printf "%s\0" "create ~a " refs/heads/main >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
grep "fatal: invalid ref format: ~a " err
'
test_expect_success 'update-ref --stdin -z fails update with bad ref name' '
printf "%s\0" "update ~a" refs/heads/master "" >stdin &&
printf "%s\0" "update ~a" refs/heads/main "" >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
grep "fatal: invalid ref format: ~a" err
'
test_expect_success 'update-ref --stdin -z fails delete with bad ref name' '
printf "%s\0" "delete ~a" refs/heads/master >stdin &&
printf "%s\0" "delete ~a" refs/heads/main >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
grep "fatal: invalid ref format: ~a" err
'

View File

@ -3,7 +3,7 @@
test_description='git fsck random collection of tests
* (HEAD) B
* (master) A
* (main) A
'
. ./test-lib.sh

View File

@ -1,6 +1,9 @@
#!/bin/sh
test_description='test git rev-parse'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_one () {
@ -229,8 +232,8 @@ test_expect_success 'showing the superproject correctly' '
test_commit -C super/dir/sub branch1_commit &&
git -C super add dir/sub &&
test_commit -C super branch1_commit &&
git -C super checkout -b branch2 master &&
git -C super/dir/sub checkout -b branch2 master &&
git -C super checkout -b branch2 main &&
git -C super/dir/sub checkout -b branch2 main &&
test_commit -C super/dir/sub branch2_commit &&
git -C super add dir/sub &&
test_commit -C super branch2_commit &&

View File

@ -6,6 +6,9 @@ test_description='test git rev-parse --verify'
exec </dev/null
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
add_line_into_file()
@ -51,8 +54,8 @@ test_expect_success 'works with one good rev' '
test "$rev_hash3" = "$HASH3" &&
rev_hash4=$(git rev-parse --verify $HASH4) &&
test "$rev_hash4" = "$HASH4" &&
rev_master=$(git rev-parse --verify master) &&
test "$rev_master" = "$HASH4" &&
rev_main=$(git rev-parse --verify main) &&
test "$rev_main" = "$HASH4" &&
rev_head=$(git rev-parse --verify HEAD) &&
test "$rev_head" = "$HASH4"
'
@ -116,27 +119,27 @@ test_expect_success 'no stdout output on error' '
'
test_expect_success 'use --default' '
git rev-parse --verify --default master &&
git rev-parse --verify --default master HEAD &&
git rev-parse --default master --verify &&
git rev-parse --default master --verify HEAD &&
git rev-parse --verify HEAD --default master &&
test_must_fail git rev-parse --verify foo --default master &&
git rev-parse --verify --default main &&
git rev-parse --verify --default main HEAD &&
git rev-parse --default main --verify &&
git rev-parse --default main --verify HEAD &&
git rev-parse --verify HEAD --default main &&
test_must_fail git rev-parse --verify foo --default main &&
test_must_fail git rev-parse --default HEAD --verify bar &&
test_must_fail git rev-parse --verify --default HEAD baz &&
test_must_fail git rev-parse --default foo --verify &&
test_must_fail git rev-parse --verify --default bar
'
test_expect_success 'master@{n} for various n' '
test_expect_success 'main@{n} for various n' '
N=$(git reflog | wc -l) &&
Nm1=$(($N-1)) &&
Np1=$(($N+1)) &&
git rev-parse --verify master@{0} &&
git rev-parse --verify master@{1} &&
git rev-parse --verify master@{$Nm1} &&
test_must_fail git rev-parse --verify master@{$N} &&
test_must_fail git rev-parse --verify master@{$Np1}
git rev-parse --verify main@{0} &&
git rev-parse --verify main@{1} &&
git rev-parse --verify main@{$Nm1} &&
test_must_fail git rev-parse --verify main@{$N} &&
test_must_fail git rev-parse --verify main@{$Np1}
'
test_expect_success SYMLINKS 'ref resolution not confused by broken symlinks' '

View File

@ -2,6 +2,9 @@
test_description='test @{-N} syntax'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
@ -20,12 +23,12 @@ test_expect_success 'setup' '
make_commit 3 &&
git checkout side &&
make_commit 4 &&
git merge master &&
git checkout master
git merge main &&
git checkout main
'
# 1 -- 2 -- 3 master
# 1 -- 2 -- 3 main
# \ \
# \ \
# --- 4 --- 5 side
@ -49,7 +52,7 @@ test_expect_success '@{-1}@{1} works' '
'
test_expect_success '@{-2} works' '
test_cmp_rev master @{-2}
test_cmp_rev main @{-2}
'
test_expect_success '@{-3} fails' '

View File

@ -4,6 +4,9 @@ test_description='test git rev-parse diagnosis for invalid argument'
exec </dev/null
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_did_you_mean ()
@ -137,10 +140,10 @@ test_expect_success 'incorrect file in :path and :N:path' '
'
test_expect_success 'invalid @{n} reference' '
test_must_fail git rev-parse master@{99999} >output 2>error &&
test_must_fail git rev-parse main@{99999} >output 2>error &&
test_must_be_empty output &&
test_i18ngrep "log for [^ ]* only has [0-9][0-9]* entries" error &&
test_must_fail git rev-parse --verify master@{99999} >output 2>error &&
test_must_fail git rev-parse --verify main@{99999} >output 2>error &&
test_must_be_empty output &&
test_i18ngrep "log for [^ ]* only has [0-9][0-9]* entries" error
'

View File

@ -2,6 +2,9 @@
test_description='test <branch>@{upstream} syntax'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
@ -10,20 +13,20 @@ test_expect_success 'setup' '
test_commit 1 &&
git checkout -b side &&
test_commit 2 &&
git checkout master &&
git checkout main &&
git clone . clone &&
test_commit 3 &&
(cd clone &&
test_commit 4 &&
git branch --track my-side origin/side &&
git branch --track local-master master &&
git branch --track local-main main &&
git branch --track fun@ny origin/side &&
git branch --track @funny origin/side &&
git branch --track funny@ origin/side &&
git remote add -t master master-only .. &&
git fetch master-only &&
git remote add -t main main-only .. &&
git fetch main-only &&
git branch bad-upstream &&
git config branch.bad-upstream.remote master-only &&
git config branch.bad-upstream.remote main-only &&
git config branch.bad-upstream.merge refs/heads/side
)
'
@ -39,7 +42,7 @@ error_message () {
}
test_expect_success '@{upstream} resolves to correct full name' '
echo refs/remotes/origin/master >expect &&
echo refs/remotes/origin/main >expect &&
git -C clone rev-parse --symbolic-full-name @{upstream} >actual &&
test_cmp expect actual &&
git -C clone rev-parse --symbolic-full-name @{UPSTREAM} >actual &&
@ -49,7 +52,7 @@ test_expect_success '@{upstream} resolves to correct full name' '
'
test_expect_success '@{u} resolves to correct full name' '
echo refs/remotes/origin/master >expect &&
echo refs/remotes/origin/main >expect &&
git -C clone rev-parse --symbolic-full-name @{u} >actual &&
test_cmp expect actual &&
git -C clone rev-parse --symbolic-full-name @{U} >actual &&
@ -132,7 +135,7 @@ test_expect_success 'checkout -b new my-side@{u} forks from the same' '
test_expect_success 'merge my-side@{u} records the correct name' '
(
cd clone &&
git checkout master &&
git checkout main &&
test_might_fail git branch -D new &&
git branch -t new my-side@{u} &&
git merge -s ours new@{u} &&
@ -143,24 +146,24 @@ test_expect_success 'merge my-side@{u} records the correct name' '
'
test_expect_success 'branch -d other@{u}' '
git checkout -t -b other master &&
git checkout -t -b other main &&
git branch -d @{u} &&
git for-each-ref refs/heads/master >actual &&
git for-each-ref refs/heads/main >actual &&
test_must_be_empty actual
'
test_expect_success 'checkout other@{u}' '
git branch -f master HEAD &&
git checkout -t -b another master &&
git branch -f main HEAD &&
git checkout -t -b another main &&
git checkout @{u} &&
git symbolic-ref HEAD >actual &&
echo refs/heads/master >expect &&
echo refs/heads/main >expect &&
test_cmp expect actual
'
test_expect_success 'branch@{u} works when tracking a local branch' '
echo refs/heads/master >expect &&
git -C clone rev-parse --symbolic-full-name local-master@{u} >actual &&
echo refs/heads/main >expect &&
git -C clone rev-parse --symbolic-full-name local-main@{u} >actual &&
test_cmp expect actual
'
@ -174,7 +177,7 @@ test_expect_success 'branch@{u} error message when no upstream' '
test_expect_success '@{u} error message when no upstream' '
cat >expect <<-EOF &&
fatal: no upstream configured for branch ${SQ}master${SQ}
fatal: no upstream configured for branch ${SQ}main${SQ}
EOF
test_must_fail git rev-parse --verify @{u} 2>actual &&
test_i18ncmp expect actual
@ -208,14 +211,14 @@ test_expect_success 'branch@{u} error message if upstream branch not fetched' '
test_expect_success 'pull works when tracking a local branch' '
(
cd clone &&
git checkout local-master &&
git checkout local-main &&
git pull
)
'
# makes sense if the previous one succeeded
test_expect_success '@{u} works when tracking a local branch' '
echo refs/heads/master >expect &&
echo refs/heads/main >expect &&
git -C clone rev-parse --symbolic-full-name @{u} >actual &&
test_cmp expect actual
'
@ -224,7 +227,7 @@ test_expect_success 'log -g other@{u}' '
commit=$(git rev-parse HEAD) &&
cat >expect <<-EOF &&
commit $commit
Reflog: master@{0} (C O Mitter <committer@example.com>)
Reflog: main@{0} (C O Mitter <committer@example.com>)
Reflog message: branch: Created from HEAD
Author: A U Thor <author@example.com>
Date: Thu Apr 7 15:15:13 2005 -0700
@ -239,7 +242,7 @@ test_expect_success 'log -g other@{u}@{now}' '
commit=$(git rev-parse HEAD) &&
cat >expect <<-EOF &&
commit $commit
Reflog: master@{Thu Apr 7 15:17:13 2005 -0700} (C O Mitter <committer@example.com>)
Reflog: main@{Thu Apr 7 15:17:13 2005 -0700} (C O Mitter <committer@example.com>)
Reflog message: branch: Created from HEAD
Author: A U Thor <author@example.com>
Date: Thu Apr 7 15:15:13 2005 -0700

View File

@ -1,6 +1,9 @@
#!/bin/sh
test_description='test various @{X} syntax combinations together'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
check() {
@ -30,8 +33,8 @@ fail() {
}
test_expect_success 'setup' '
test_commit master-one &&
test_commit master-two &&
test_commit main-one &&
test_commit main-two &&
git checkout -b upstream-branch &&
test_commit upstream-one &&
test_commit upstream-two &&
@ -47,7 +50,7 @@ test_expect_success 'setup' '
git checkout -b new-branch &&
test_commit new-one &&
test_commit new-two &&
git branch -u master old-branch &&
git branch -u main old-branch &&
git branch -u upstream-branch new-branch
'
@ -62,8 +65,8 @@ check "@{-1}@{1}" commit old-one
check "@{u}" ref refs/heads/upstream-branch
check "HEAD@{u}" ref refs/heads/upstream-branch
check "@{u}@{1}" commit upstream-one
check "@{-1}@{u}" ref refs/heads/master
check "@{-1}@{u}@{1}" commit master-one
check "@{-1}@{u}" ref refs/heads/main
check "@{-1}@{u}@{1}" commit main-one
check "@" commit new-two
check "@@{u}" ref refs/heads/upstream-branch
check "@@/at-test" ref refs/heads/@@/at-test
@ -100,14 +103,14 @@ check "@:normal" blob content
check "@:fun@ny" blob content
test_expect_success '@{1} works with only one reflog entry' '
git checkout -B newbranch master &&
git checkout -B newbranch main &&
git reflog expire --expire=now refs/heads/newbranch &&
git commit --allow-empty -m "first after expiration" &&
test_cmp_rev newbranch~ newbranch@{1}
'
test_expect_success '@{0} works with empty reflog' '
git checkout -B newbranch master &&
git checkout -B newbranch main &&
git reflog expire --expire=now refs/heads/newbranch &&
test_cmp_rev newbranch newbranch@{0}
'

View File

@ -2,6 +2,9 @@
test_description='tests for ref^{stuff}'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'setup' '
@ -15,7 +18,7 @@ test_expect_success 'setup' '
git commit -m Initial &&
git tag -a -m commit commit-tag &&
git branch ref &&
git checkout master &&
git checkout main &&
echo modified >>a-blob &&
git add -u &&
git commit -m Modified &&
@ -73,52 +76,52 @@ test_expect_success 'ref^{tag}' '
'
test_expect_success 'ref^{/.}' '
git rev-parse master >expected &&
git rev-parse master^{/.} >actual &&
git rev-parse main >expected &&
git rev-parse main^{/.} >actual &&
test_cmp expected actual
'
test_expect_success 'ref^{/non-existent}' '
test_must_fail git rev-parse master^{/non-existent}
test_must_fail git rev-parse main^{/non-existent}
'
test_expect_success 'ref^{/Initial}' '
git rev-parse ref >expected &&
git rev-parse master^{/Initial} >actual &&
git rev-parse main^{/Initial} >actual &&
test_cmp expected actual
'
test_expect_success 'ref^{/!Exp}' '
test_must_fail git rev-parse master^{/!Exp}
test_must_fail git rev-parse main^{/!Exp}
'
test_expect_success 'ref^{/!}' '
test_must_fail git rev-parse master^{/!}
test_must_fail git rev-parse main^{/!}
'
test_expect_success 'ref^{/!!Exp}' '
git rev-parse expref >expected &&
git rev-parse master^{/!!Exp} >actual &&
git rev-parse main^{/!!Exp} >actual &&
test_cmp expected actual
'
test_expect_success 'ref^{/!-}' '
test_must_fail git rev-parse master^{/!-}
test_must_fail git rev-parse main^{/!-}
'
test_expect_success 'ref^{/!-.}' '
test_must_fail git rev-parse master^{/!-.}
test_must_fail git rev-parse main^{/!-.}
'
test_expect_success 'ref^{/!-non-existent}' '
git rev-parse master >expected &&
git rev-parse master^{/!-non-existent} >actual &&
git rev-parse main >expected &&
git rev-parse main^{/!-non-existent} >actual &&
test_cmp expected actual
'
test_expect_success 'ref^{/!-Changed}' '
git rev-parse expref >expected &&
git rev-parse master^{/!-Changed} >actual &&
git rev-parse main^{/!-Changed} >actual &&
test_cmp expected actual
'

View File

@ -20,6 +20,9 @@ one tagged as v1.0.0. They all have one regular file each.
'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
if ! test_have_prereq SHA1
@ -212,7 +215,7 @@ test_expect_success 'more history' '
side=$(git rev-parse HEAD) &&
# commit 000000000066
git checkout master &&
git checkout main &&
# If you use recursive, merge will fail and you will need to
# clean up a0blgqsjc as well. If you use resolve, merge will

View File

@ -2,6 +2,9 @@
test_description='Tests for rev-parse --prefix'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'setup' '
@ -76,9 +79,9 @@ test_expect_success 'disambiguate path with valid prefix' '
'
test_expect_success 'file and refs with prefix' '
git rev-parse --prefix sub1/ master file1 >actual &&
git rev-parse --prefix sub1/ main file1 >actual &&
cat <<-EOF >expected &&
$(git rev-parse master)
$(git rev-parse main)
sub1/file1
EOF
test_cmp expected actual

View File

@ -1,6 +1,9 @@
#!/bin/sh
test_description='test <branch>@{push} syntax'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
resolve () {
@ -16,24 +19,24 @@ test_expect_success 'setup' '
git remote add other other.git &&
test_commit base &&
git push origin HEAD &&
git branch --set-upstream-to=origin/master master &&
git branch --track topic origin/master &&
git branch --set-upstream-to=origin/main main &&
git branch --track topic origin/main &&
git push origin topic &&
git push other topic
'
test_expect_success '@{push} with default=nothing' '
test_config push.default nothing &&
test_must_fail git rev-parse master@{push} &&
test_must_fail git rev-parse master@{PUSH} &&
test_must_fail git rev-parse master@{PuSH}
test_must_fail git rev-parse main@{push} &&
test_must_fail git rev-parse main@{PUSH} &&
test_must_fail git rev-parse main@{PuSH}
'
test_expect_success '@{push} with default=simple' '
test_config push.default simple &&
resolve master@{push} refs/remotes/origin/master &&
resolve master@{PUSH} refs/remotes/origin/master &&
resolve master@{pUSh} refs/remotes/origin/master
resolve main@{push} refs/remotes/origin/main &&
resolve main@{PUSH} refs/remotes/origin/main &&
resolve main@{pUSh} refs/remotes/origin/main
'
test_expect_success 'triangular @{push} fails with default=simple' '

View File

@ -2,6 +2,9 @@
test_description='split index mode tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
# We need total control of index splitting here
@ -496,7 +499,7 @@ test_expect_success 'do not refresh null base index' '
test_commit initial &&
git checkout -b side-branch &&
test_commit extra &&
git checkout master &&
git checkout main &&
git update-index --split-index &&
test_commit more &&
# must not write a new shareindex, or we wont catch the problem

View File

@ -4,6 +4,9 @@
test_description='git checkout to switch between branches with symlink<->dir'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '
@ -12,14 +15,14 @@ test_expect_success setup '
echo hello >frotz/filfre &&
git add frotz/filfre &&
test_tick &&
git commit -m "master has file frotz/filfre" &&
git commit -m "main has file frotz/filfre" &&
git branch side &&
echo goodbye >nitfol &&
git add nitfol &&
test_tick &&
git commit -m "master adds file nitfol" &&
git commit -m "main adds file nitfol" &&
git checkout side &&
@ -34,13 +37,13 @@ test_expect_success setup '
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 &&
git checkout -f master
git checkout -f main
'
test_expect_success 'switch from dir to symlink' '

View File

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

View File

@ -2,6 +2,9 @@
test_description='checkout and pathspecs/refspecs ambiguities'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'setup' '
@ -17,7 +20,7 @@ test_expect_success 'reference must be a tree' '
'
test_expect_success 'branch switching' '
test "refs/heads/master" = "$(git symbolic-ref HEAD)" &&
test "refs/heads/main" = "$(git symbolic-ref HEAD)" &&
git checkout world -- &&
test "refs/heads/world" = "$(git symbolic-ref HEAD)"
'
@ -57,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_must_fail git checkout HEAD master -- 2>actual &&
test_must_fail git checkout HEAD main -- 2>actual &&
test_i18ngrep 2 actual &&
test_i18ngrep "one reference expected, 2 given" actual
'

View File

@ -2,6 +2,9 @@
test_description='checkout switching away from an invalid branch'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'setup' '
@ -11,12 +14,12 @@ test_expect_success 'setup' '
'
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 &&
git checkout master --
git checkout main --
'
test_expect_success 'checkout notices failure to lock HEAD' '
@ -26,7 +29,7 @@ test_expect_success 'checkout notices failure to lock HEAD' '
'
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,
# as it may use the same code we are testing
@ -37,12 +40,12 @@ test_expect_success 'create ref directory/file conflict scenario' '
test_expect_success 'checkout away from d/f HEAD (unpacked, to branch)' '
reset_to_df &&
git checkout master
git checkout main
'
test_expect_success 'checkout away from d/f HEAD (unpacked, to detached)' '
reset_to_df &&
git checkout --detach master
git checkout --detach main
'
test_expect_success 'pack refs' '
@ -51,11 +54,11 @@ test_expect_success 'pack refs' '
test_expect_success 'checkout away from d/f HEAD (packed, to branch)' '
reset_to_df &&
git checkout master
git checkout main
'
test_expect_success 'checkout away from d/f HEAD (packed, to detached)' '
reset_to_df &&
git checkout --detach master
git checkout --detach main
'
test_done

View File

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

View File

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

View File

@ -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
'

View File

@ -1,6 +1,9 @@
#!/bin/sh
test_description='checkout into detached HEAD state'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
check_detached () {
@ -22,7 +25,7 @@ check_no_orphan_warning() {
}
reset () {
git checkout master &&
git checkout main &&
check_not_detached
}
@ -85,7 +88,7 @@ test_expect_success 'checkout --detach errors out for non-commit' '
test_expect_success 'checkout --detach errors out for extra argument' '
reset &&
git checkout master &&
git checkout main &&
test_must_fail git checkout --detach tag one.t &&
check_not_detached
'
@ -113,7 +116,7 @@ test_expect_success 'checkout warns on orphan commits' '
echo new content >orphan &&
git commit -a -m orphan2 &&
orphan2=$(git rev-parse HEAD) &&
git checkout master 2>stderr
git checkout main 2>stderr
'
test_expect_success 'checkout warns on orphan commits: output' '
@ -132,7 +135,7 @@ test_expect_success 'checkout warns orphaning 1 of 2 commits: output' '
test_expect_success 'checkout does not warn leaving ref tip' '
reset &&
git checkout --detach two &&
git checkout master 2>stderr
git checkout main 2>stderr
'
test_expect_success 'checkout does not warn leaving ref tip' '
@ -142,7 +145,7 @@ test_expect_success 'checkout does not warn leaving ref tip' '
test_expect_success 'checkout does not warn leaving reachable commit' '
reset &&
git checkout --detach HEAD^ &&
git checkout master 2>stderr
git checkout main 2>stderr
'
test_expect_success 'checkout does not warn leaving reachable commit' '
@ -150,14 +153,14 @@ test_expect_success 'checkout does not warn leaving reachable commit' '
'
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)
EOF
test_expect_success 'tracking count is accurate after orphan check' '
reset &&
git branch child master^ &&
git branch child main^ &&
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 >stdout &&
test_i18ncmp expect stdout
@ -189,9 +192,9 @@ test_expect_success 'no advice given for explicit detached head state' '
# 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' "
commit=$(git rev-parse --short=12 master^) &&
commit2=$(git rev-parse --short=12 master~2) &&
commit3=$(git rev-parse --short=12 master~3) &&
commit=$(git rev-parse --short=12 main^) &&
commit2=$(git rev-parse --short=12 main~2) &&
commit3=$(git rev-parse --short=12 main~3) &&
# The first detach operation is more chatty than the following ones.
cat >1st_detach <<-EOF &&
@ -271,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)
test_expect_success 'describe_detached_head does print SHA-1 ellipsis when asked to' "
commit=$(git rev-parse --short=12 master^) &&
commit2=$(git rev-parse --short=12 master~2) &&
commit3=$(git rev-parse --short=12 master~3) &&
commit=$(git rev-parse --short=12 main^) &&
commit2=$(git rev-parse --short=12 main~2) &&
commit3=$(git rev-parse --short=12 main~3) &&
# The first detach operation is more chatty than the following ones.
cat >1st_detach <<-EOF &&

View File

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

View File

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

View File

@ -29,11 +29,11 @@ status_uno_is_clean () {
}
test_expect_success 'setup' '
test_commit my_master &&
test_commit my_main &&
git init repo_a &&
(
cd repo_a &&
test_commit a_master &&
test_commit a_main &&
git checkout -b foo &&
test_commit a_foo &&
git checkout -b bar &&
@ -44,7 +44,7 @@ test_expect_success 'setup' '
git init repo_b &&
(
cd repo_b &&
test_commit b_master &&
test_commit b_main &&
git checkout -b foo &&
test_commit b_foo &&
git checkout -b baz &&
@ -60,23 +60,23 @@ test_expect_success 'setup' '
'
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_must_fail git checkout xyzzy &&
status_uno_is_clean &&
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' '
git checkout -B master &&
git checkout -B main &&
test_might_fail git branch -D foo &&
test_must_fail git checkout foo &&
status_uno_is_clean &&
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' '
@ -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' '
git checkout -B master &&
git checkout -B main &&
test_might_fail git branch -D foo &&
test_must_fail git checkout foo 2>stderr &&
test_branch master &&
test_branch main &&
status_uno_is_clean &&
test_i18ngrep "^hint: " stderr &&
test_must_fail git -c advice.checkoutAmbiguousRemoteBranchName=false \
checkout foo 2>stderr &&
test_branch master &&
test_branch main &&
status_uno_is_clean &&
test_i18ngrep ! "^hint: " stderr
'
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 &&
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' '
git checkout -B master &&
git checkout -B main &&
status_uno_is_clean &&
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' '
git checkout -B master &&
git checkout -B main &&
test_might_fail git branch -D 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' '
git checkout -B master &&
git checkout -B main &&
test_might_fail git branch -D 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' '
git checkout -B master &&
git checkout -B main &&
status_uno_is_clean &&
test_might_fail git branch -D bar &&
test_must_fail git checkout --no-guess 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' '
git checkout -B master &&
git checkout -B main &&
status_uno_is_clean &&
test_might_fail git branch -D bar &&
test_config checkout.guess false &&
test_must_fail git checkout 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' '
git checkout -B master &&
git checkout -B main &&
status_uno_is_clean &&
git init repo_c &&
(
cd repo_c &&
test_commit c_master &&
test_commit c_main &&
git checkout -b bar &&
test_commit c_bar &&
git checkout -b spam &&
@ -192,7 +192,7 @@ test_expect_success 'setup more remotes with unconventional refspecs' '
git init repo_d &&
(
cd repo_d &&
test_commit d_master &&
test_commit d_main &&
git checkout -b baz &&
test_commit d_baz &&
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' '
git checkout -B master &&
git checkout -B main &&
status_uno_is_clean &&
test_might_fail git branch -D bar &&
test_must_fail git checkout bar &&
status_uno_is_clean &&
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' '
git checkout -B master &&
git checkout -B main &&
status_uno_is_clean &&
test_might_fail git branch -D baz &&
test_must_fail git checkout baz &&
status_uno_is_clean &&
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' '
git checkout -B master &&
git checkout -B main &&
status_uno_is_clean &&
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' '
git checkout -B master &&
git checkout -B main &&
status_uno_is_clean &&
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' '
git checkout -B master &&
git checkout -B main &&
status_uno_is_clean &&
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 &&
status_uno_is_clean &&
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' '
git checkout -B master &&
git checkout -B main &&
status_uno_is_clean &&
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 &&
status_uno_is_clean &&
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' '
git checkout -B master &&
git checkout -B main &&
status_uno_is_clean &&
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' '
git checkout master &&
git checkout main &&
status_uno_is_clean &&
git branch strict &&
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.loose.remote . &&
test_config branch.strict.merge refs/heads/master &&
test_config branch.loose.merge master &&
test_config branch.strict.merge refs/heads/main &&
test_config branch.loose.merge main &&
git checkout strict | sed -e "s/strict/BRANCHNAME/g" >expect &&
status_uno_is_clean &&

View File

@ -2,6 +2,9 @@
test_description='tests for git branch --track'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'setup' '
@ -10,14 +13,14 @@ test_expect_success 'setup' '
'
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 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_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
'

View File

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

View File

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

View File

@ -2,6 +2,9 @@
test_description='restore basic functionality'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'setup' '
@ -15,7 +18,7 @@ test_expect_success 'setup' '
echo ignored >ignored &&
echo /ignored >.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' '
@ -91,7 +94,7 @@ test_expect_success 'restore --ignore-unmerged ignores unmerged entries' '
git switch -c first &&
echo first >unmerged &&
git commit -am first &&
git switch -c second master &&
git switch -c second main &&
echo second >unmerged &&
git commit -am second &&
test_must_fail git merge first &&

View File

@ -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/*" &&

View File

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

View File

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

View File

@ -2,6 +2,9 @@
test_description='Combination of submodules and multiple worktrees'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
base_path=$(pwd -P)
@ -31,7 +34,7 @@ test_expect_success 'add superproject worktree' '
'
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
'
@ -41,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' '
git -C worktree-submodule-update diff --submodule master"^!" >out &&
git -C worktree-submodule-update diff --submodule main"^!" >out &&
grep "file1 updated" out
'
@ -51,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' '
git -C linked_submodule diff --submodule master"^!" >out &&
git -C linked_submodule diff --submodule main"^!" >out &&
grep "file1 updated" out
'

View File

@ -5,6 +5,9 @@
test_description='git branch assorted tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-rebase.sh

View File

@ -2,6 +2,9 @@
test_description='branch --contains <commit>, --no-contains <commit> --merged, and --no-merged'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '

View File

@ -2,6 +2,9 @@
test_description='test show-branch with more than 8 heads'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
numbers="1 2 3 4 5 6 7 8 9 10"
@ -15,7 +18,7 @@ test_expect_success 'setup' '
for i in $numbers
do
git checkout -b branch$i master &&
git checkout -b branch$i main &&
> file$i &&
git add file$i &&
test_tick &&

View File

@ -1,6 +1,9 @@
#!/bin/sh
test_description='git branch display tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-terminal.sh

View File

@ -6,6 +6,9 @@ Branch name arguments are usually names which are taken to be inside of
refs/heads/, but we interpret some magic syntax like @{-1}, @{upstream}, etc.
This script aims to check the behavior of those corner cases.
'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
expect_branch() {
@ -28,7 +31,7 @@ test_expect_success 'update branch via @{-1}' '
git branch previous one &&
git checkout previous &&
git checkout master &&
git checkout main &&
git branch -f @{-1} two &&
expect_branch previous two
@ -58,7 +61,7 @@ test_expect_success 'delete branch via @{-1}' '
git branch previous-del &&
git checkout previous-del &&
git checkout master &&
git checkout main &&
git branch -D @{-1} &&
expect_deleted previous-del
@ -98,7 +101,7 @@ test_expect_success 'disallow deleting remote branch via @{-1}' '
git update-ref refs/remotes/origin/previous one &&
git checkout -b origin/previous two &&
git checkout master &&
git checkout main &&
test_must_fail git branch -r -D @{-1} &&
expect_branch refs/remotes/origin/previous one &&

View File

@ -1,6 +1,9 @@
#!/bin/sh
test_description='basic branch output coloring'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'set up some sample branches' '

View File

@ -2,6 +2,9 @@
test_description='range-diff tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
# Note that because of the range-diff's heuristics, test_commit does more
@ -127,7 +130,7 @@ test_expect_success 'setup' '
'
test_expect_success 'simple A..B A..C (unmodified)' '
git range-diff --no-color master..topic master..unmodified \
git range-diff --no-color main..topic main..unmodified \
>actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
@ -145,13 +148,13 @@ test_expect_success 'simple B...C (unmodified)' '
'
test_expect_success 'simple A B C (unmodified)' '
git range-diff --no-color master topic unmodified >actual &&
git range-diff --no-color main topic unmodified >actual &&
# same "expect" as above
test_cmp expect actual
'
test_expect_success 'trivial reordering' '
git range-diff --no-color master topic reordered >actual &&
git range-diff --no-color main topic reordered >actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid r1) s/5/A/
3: $(test_oid t3) = 2: $(test_oid r2) s/11/B/
@ -162,7 +165,7 @@ test_expect_success 'trivial reordering' '
'
test_expect_success 'removed a commit' '
git range-diff --no-color master topic removed >actual &&
git range-diff --no-color main topic removed >actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid d1) s/5/A/
2: $(test_oid t2) < -: $(test_oid __) s/4/A/
@ -173,7 +176,7 @@ test_expect_success 'removed a commit' '
'
test_expect_success 'added a commit' '
git range-diff --no-color master topic added >actual &&
git range-diff --no-color main topic added >actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid a1) s/5/A/
2: $(test_oid t2) = 2: $(test_oid a2) s/4/A/
@ -185,7 +188,7 @@ test_expect_success 'added a commit' '
'
test_expect_success 'new base, A B C' '
git range-diff --no-color master topic rebased >actual &&
git range-diff --no-color main topic rebased >actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid b1) s/5/A/
2: $(test_oid t2) = 2: $(test_oid b2) s/4/A/
@ -196,7 +199,7 @@ test_expect_success 'new base, A B C' '
'
test_expect_success 'new base, B...C' '
# this syntax includes the commits from master!
# this syntax includes the commits from main!
git range-diff --no-color topic...rebased >actual &&
cat >expect <<-EOF &&
-: $(test_oid __) > 1: $(test_oid b5) unrelated
@ -420,7 +423,7 @@ test_expect_success 'file added and later removed' '
test_expect_success 'no commits on one side' '
git commit --amend -m "new message" &&
git range-diff master HEAD@{1} HEAD
git range-diff main HEAD@{1} HEAD
'
test_expect_success 'changed message' '
@ -482,11 +485,11 @@ test_expect_success 'dual-coloring' '
test_cmp expect actual
'
for prev in topic master..topic
for prev in topic main..topic
do
test_expect_success "format-patch --range-diff=$prev" '
git format-patch --cover-letter --range-diff=$prev \
master..unmodified >actual &&
main..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
test_i18ngrep "^Range-diff:$" 0000-* &&
@ -511,19 +514,19 @@ test_expect_success 'range-diff overrides diff.noprefix internally' '
test_expect_success 'basic with modified format.pretty with suffix' '
git -c format.pretty="format:commit %H%d%n" range-diff \
master..topic master..unmodified
main..topic main..unmodified
'
test_expect_success 'basic with modified format.pretty without "commit "' '
git -c format.pretty="format:%H%n" range-diff \
master..topic master..unmodified
main..topic main..unmodified
'
test_expect_success 'range-diff compares notes by default' '
git notes add -m "topic note" topic &&
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
git range-diff --no-color master..topic master..unmodified \
git range-diff --no-color main..topic main..unmodified \
>actual &&
sed s/Z/\ /g >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
@ -547,7 +550,7 @@ test_expect_success 'range-diff with --no-notes' '
git notes add -m "topic note" topic &&
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
git range-diff --no-color --no-notes master..topic master..unmodified \
git range-diff --no-color --no-notes main..topic main..unmodified \
>actual &&
cat >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
@ -565,7 +568,7 @@ test_expect_success 'range-diff with multiple --notes' '
git notes --ref=note2 add -m "topic note2" topic &&
git notes --ref=note2 add -m "unmodified note2" unmodified &&
test_when_finished git notes --ref=note2 remove topic unmodified &&
git range-diff --no-color --notes=note1 --notes=note2 master..topic master..unmodified \
git range-diff --no-color --notes=note1 --notes=note2 main..topic main..unmodified \
>actual &&
sed s/Z/\ /g >expect <<-EOF &&
1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
@ -595,7 +598,7 @@ test_expect_success 'format-patch --range-diff does not compare notes by default
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
git format-patch --cover-letter --range-diff=$prev \
master..unmodified >actual &&
main..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
test_i18ngrep "^Range-diff:$" 0000-* &&
@ -612,7 +615,7 @@ test_expect_success 'format-patch --range-diff with --no-notes' '
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
git format-patch --no-notes --cover-letter --range-diff=$prev \
master..unmodified >actual &&
main..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
test_i18ngrep "^Range-diff:$" 0000-* &&
@ -629,7 +632,7 @@ test_expect_success 'format-patch --range-diff with --notes' '
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
git format-patch --notes --cover-letter --range-diff=$prev \
master..unmodified >actual &&
main..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
test_i18ngrep "^Range-diff:$" 0000-* &&
@ -658,7 +661,7 @@ test_expect_success 'format-patch --range-diff with format.notes config' '
test_when_finished git notes remove topic unmodified &&
test_config format.notes true &&
git format-patch --cover-letter --range-diff=$prev \
master..unmodified >actual &&
main..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
test_i18ngrep "^Range-diff:$" 0000-* &&
@ -689,7 +692,7 @@ test_expect_success 'format-patch --range-diff with multiple notes' '
git notes --ref=note2 add -m "unmodified note2" unmodified &&
test_when_finished git notes --ref=note2 remove topic unmodified &&
git format-patch --notes=note1 --notes=note2 --cover-letter --range-diff=$prev \
master..unmodified >actual &&
main..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
test_i18ngrep "^Range-diff:$" 0000-* &&

View File

@ -168,7 +168,7 @@ mark :11
data 10
unrelated
commit refs/heads/master
commit refs/heads/main
mark :12
author Thomas Rast <trast@inf.ethz.ch> 1374485127 +0200
committer Thomas Rast <trast@inf.ethz.ch> 1374485127 +0200

View File

@ -9,6 +9,9 @@ test_description='git pack-refs should not change the branch semantic
This test runs git pack-refs and git show-ref and checks that the branch
semantic is still the same.
'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'enable reflogs' '
@ -135,7 +138,7 @@ test_expect_success 'delete ref with dangling packed version' '
git commit --allow-empty -m "future garbage" &&
git pack-refs --all &&
git reset --hard HEAD^ &&
git checkout master &&
git checkout main &&
git reflog expire --expire=all --all &&
git prune --expire=all &&
git branch -d lamb 2>result &&
@ -240,7 +243,7 @@ test_expect_success 'retry acquiring packed-refs.lock' '
test_expect_success SYMLINKS 'pack symlinked packed-refs' '
# First make sure that symlinking works when reading:
git update-ref refs/heads/lossy refs/heads/master &&
git update-ref refs/heads/lossy refs/heads/main &&
git for-each-ref >all-refs-before &&
mv .git/packed-refs .git/my-deviant-packed-refs &&
ln -s my-deviant-packed-refs .git/packed-refs &&

View File

@ -1,6 +1,9 @@
#!/bin/sh
test_description='tests for the peel_ref optimization of packed-refs'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'create annotated tag in refs/tags' '
@ -19,7 +22,7 @@ print_ref() {
test_expect_success 'set up expected show-ref output' '
{
print_ref "refs/heads/master" &&
print_ref "refs/heads/main" &&
print_ref "refs/outside/foo" &&
print_ref "refs/outside/foo^{}" &&
print_ref "refs/tags/base" &&
@ -47,7 +50,7 @@ test_expect_success 'create old-style pack-refs without fully-peeled' '
# know we are emulating exactly what an older git would have written.
{
echo "# pack-refs with: peeled " &&
print_ref "refs/heads/master" &&
print_ref "refs/heads/main" &&
print_ref "refs/outside/foo" &&
print_ref "refs/tags/base" &&
print_ref "refs/tags/foo" &&

View File

@ -1300,11 +1300,11 @@ test_expect_success 'git notes copy diagnoses too many or too few parameters' '
test_i18ngrep "too many parameters" error
'
test_expect_success 'git notes get-ref expands refs/heads/master to refs/notes/refs/heads/master' '
test_expect_success 'git notes get-ref expands refs/heads/main to refs/notes/refs/heads/main' '
test_unconfig core.notesRef &&
sane_unset GIT_NOTES_REF &&
echo refs/notes/refs/heads/master >expect &&
git notes --ref=refs/heads/master get-ref >actual &&
echo refs/notes/refs/heads/main >expect &&
git notes --ref=refs/heads/main get-ref >actual &&
test_cmp expect actual
'

View File

@ -5,6 +5,9 @@
test_description='Test commit notes index (expensive!)'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
create_repo () {
@ -20,7 +23,7 @@ create_repo () {
notemark=$(($mark+1))
test_tick &&
cat <<-INPUT_END &&
commit refs/heads/master
commit refs/heads/main
mark :$mark
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT

View File

@ -2,6 +2,9 @@
test_description='Test commit notes organized in subtrees'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
number_of_commits=100
@ -40,7 +43,7 @@ test_expect_success "setup: create $number_of_commits commits" '
nr=$(($nr+1)) &&
test_tick &&
cat <<INPUT_END
commit refs/heads/master
commit refs/heads/main
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
commit #$nr
@ -75,7 +78,7 @@ test_sha1_based () {
(
start_note_commit &&
nr=$number_of_commits &&
git rev-list refs/heads/master |
git rev-list refs/heads/main |
while read sha1; do
note_path=$(echo "$sha1" | sed "$1")
cat <<INPUT_END &&
@ -105,7 +108,7 @@ test_same_notes () {
(
start_note_commit &&
nr=$number_of_commits &&
git rev-list refs/heads/master |
git rev-list refs/heads/main |
while read sha1; do
first_note_path=$(echo "$sha1" | sed "$1")
second_note_path=$(echo "$sha1" | sed "$2")
@ -144,7 +147,7 @@ test_concatenated_notes () {
(
start_note_commit &&
nr=$number_of_commits &&
git rev-list refs/heads/master |
git rev-list refs/heads/main |
while read sha1; do
first_note_path=$(echo "$sha1" | sed "$1")
second_note_path=$(echo "$sha1" | sed "$2")

View File

@ -2,6 +2,9 @@
test_description='Test notes trees that also contain non-notes'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
number_of_commits=100
@ -36,7 +39,7 @@ test_expect_success "setup: create a couple of commits" '
test_tick &&
cat <<INPUT_END >input &&
commit refs/heads/master
commit refs/heads/main
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
commit #1
@ -51,7 +54,7 @@ INPUT_END
test_tick &&
cat <<INPUT_END >>input &&
commit refs/heads/master
commit refs/heads/main
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
commit #2
@ -68,8 +71,8 @@ INPUT_END
test_expect_success "create a notes tree with both notes and non-notes" '
commit1=$(git rev-parse refs/heads/master^) &&
commit2=$(git rev-parse refs/heads/master) &&
commit1=$(git rev-parse refs/heads/main^) &&
commit2=$(git rev-parse refs/heads/main) &&
test_tick &&
cat <<INPUT_END >input &&
commit refs/notes/commits

View File

@ -108,7 +108,7 @@ test_expect_success 'fail to merge into various non-notes refs' '
git update-ref refs/notes/dir/foo HEAD &&
test_must_fail git -c "core.notesRef=refs/notes/dir" notes merge x &&
test_must_fail git -c "core.notesRef=refs/notes/dir/" notes merge x &&
test_must_fail git -c "core.notesRef=refs/heads/master" notes merge x &&
test_must_fail git -c "core.notesRef=refs/heads/main" notes merge x &&
test_must_fail git -c "core.notesRef=refs/notes/y:" notes merge x &&
test_must_fail git -c "core.notesRef=refs/notes/y:foo" notes merge x &&
test_must_fail git -c "core.notesRef=refs/notes/foo^{bar" notes merge x

View File

@ -5,6 +5,9 @@
test_description='Test merging of notes trees in multiple worktrees'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'setup commit' '
@ -36,8 +39,8 @@ test_expect_success 'modify notes ref ourselves (x)' '
'
test_expect_success 'create some new worktrees' '
git worktree add -b newbranch worktree master &&
git worktree add -b newbranch2 worktree2 master
git worktree add -b newbranch worktree main &&
git worktree add -b newbranch2 worktree2 main
'
test_expect_success 'merge z into y fails and sets NOTES_MERGE_REF' '

View File

@ -8,6 +8,9 @@ test_description='git rebase assorted tests
This test runs git rebase and checks that the author information is not lost
among other things.
'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
GIT_AUTHOR_NAME=author@name
@ -24,15 +27,15 @@ test_expect_success 'prepare repository with topic branches' '
git update-index --add Y &&
git commit -m "Add Y." &&
git checkout -b filemove &&
git reset --soft master &&
git reset --soft main &&
mkdir D &&
git mv A D/A &&
git commit -m "Move A." &&
git checkout -b my-topic-branch master &&
git checkout -b my-topic-branch main &&
echo Second >B &&
git update-index --add B &&
git commit -m "Add B." &&
git checkout -f master &&
git checkout -f main &&
echo Third >>A &&
git update-index A &&
git commit -m "Modify A." &&
@ -46,23 +49,23 @@ test_expect_success 'prepare repository with topic branches' '
test_expect_success 'rebase on dirty worktree' '
echo dirty >>A &&
test_must_fail git rebase master
test_must_fail git rebase main
'
test_expect_success 'rebase on dirty cache' '
git add A &&
test_must_fail git rebase master
test_must_fail git rebase main
'
test_expect_success 'rebase against master' '
test_expect_success 'rebase against main' '
git reset --hard HEAD &&
git rebase master
git rebase main
'
test_expect_success 'rebase sets ORIG_HEAD to pre-rebase state' '
git checkout -b orig-head topic &&
pre="$(git rev-parse --verify HEAD)" &&
git rebase master &&
git rebase main &&
test_cmp_rev "$pre" ORIG_HEAD &&
test_cmp_rev ! "$pre" HEAD
'
@ -93,19 +96,19 @@ test_expect_success 'HEAD was detached during rebase' '
test_expect_success 'rebase from ambiguous branch name' '
git checkout -b topic side &&
git rebase master
git rebase main
'
test_expect_success 'rebase off of the previous branch using "-"' '
git checkout master &&
git checkout main &&
git checkout HEAD^ &&
git rebase @{-1} >expect.messages &&
git merge-base master HEAD >expect.forkpoint &&
git merge-base main HEAD >expect.forkpoint &&
git checkout master &&
git checkout main &&
git checkout HEAD^ &&
git rebase - >actual.messages &&
git merge-base master HEAD >actual.forkpoint &&
git merge-base main HEAD >actual.forkpoint &&
test_cmp expect.forkpoint actual.forkpoint &&
# the next one is dubious---we may want to say "-",
@ -114,7 +117,7 @@ test_expect_success 'rebase off of the previous branch using "-"' '
'
test_expect_success 'rebase a single mode change' '
git checkout master &&
git checkout main &&
git branch -D topic &&
echo 1 >X &&
git add X &&
@ -126,7 +129,7 @@ test_expect_success 'rebase a single mode change' '
test_chmod +x A &&
test_tick &&
git commit -m modechange &&
GIT_TRACE=1 git rebase master
GIT_TRACE=1 git rebase main
'
test_expect_success 'rebase is not broken by diff.renames' '
@ -162,11 +165,11 @@ test_expect_success 'fail when upstream arg is missing and not configured' '
test_expect_success 'rebase works with format.useAutoBase' '
test_config format.useAutoBase true &&
git checkout topic &&
git rebase master
git rebase main
'
test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg (--merge)' '
git checkout -b default-base master &&
git checkout -b default-base main &&
git checkout -b default topic &&
git config branch.default.remote . &&
git config branch.default.merge refs/heads/default-base &&
@ -184,7 +187,7 @@ test_expect_success 'default to common base in @{upstream}s reflog if no upstrea
'
test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg (--apply)' '
git checkout -B default-base master &&
git checkout -B default-base main &&
git checkout -B default topic &&
git config branch.default.remote . &&
git config branch.default.merge refs/heads/default-base &&
@ -226,13 +229,13 @@ test_expect_success 'cherry-picked commits and fork-point work together' '
test_expect_success 'rebase --apply -q is quiet' '
git checkout -b quiet topic &&
git rebase --apply -q master >output.out 2>&1 &&
git rebase --apply -q main >output.out 2>&1 &&
test_must_be_empty output.out
'
test_expect_success 'rebase --merge -q is quiet' '
git checkout -B quiet topic &&
git rebase --merge -q master >output.out 2>&1 &&
git rebase --merge -q main >output.out 2>&1 &&
test_must_be_empty output.out
'
@ -294,7 +297,7 @@ test_expect_success 'rebase commit with an ancient timestamp' '
'
test_expect_success 'rebase with "From " line in commit message' '
git checkout -b preserve-from master~1 &&
git checkout -b preserve-from main~1 &&
cat >From_.msg <<EOF &&
Somebody embedded an mbox in a commit message
@ -310,7 +313,7 @@ EOF
>From_ &&
git add From_ &&
git commit -F From_.msg &&
git rebase master &&
git rebase main &&
git log -1 --pretty=format:%B >out &&
test_cmp From_.msg out
'
@ -357,12 +360,12 @@ test_expect_success 'rebase --apply and .gitattributes' '
git cherry-pick test &&
git checkout test &&
git rebase master &&
git rebase main &&
grep "smudged" a.txt &&
git checkout removal &&
git reset --hard &&
git rebase master &&
git rebase main &&
grep "clean" a.txt
)
'
@ -402,20 +405,20 @@ test_expect_success 'rebase -c rebase.useBuiltin=false warning' '
'
test_expect_success 'switch to branch checked out here' '
git checkout master &&
git rebase master master
git checkout main &&
git rebase main main
'
test_expect_success 'switch to branch not checked out' '
git checkout master &&
git checkout main &&
git branch other &&
git rebase master other
git rebase main other
'
test_expect_success 'refuse to switch to branch checked out elsewhere' '
git checkout master &&
git checkout main &&
git worktree add wt &&
test_must_fail git -C wt rebase master master 2>err &&
test_must_fail git -C wt rebase main main 2>err &&
test_i18ngrep "already checked out" err
'

View File

@ -5,6 +5,9 @@
test_description='git rebase --merge test'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
T="A quick brown fox
@ -19,10 +22,10 @@ test_expect_success setup '
git commit -m"initial" &&
git branch side &&
echo "11 $T" >>original &&
git commit -a -m"master updates a bit." &&
git commit -a -m"main updates a bit." &&
echo "12 $T" >>original &&
git commit -a -m"master updates a bit more." &&
git commit -a -m"main updates a bit more." &&
git checkout side &&
(echo "0 $T" && cat original) >renamed &&
@ -47,13 +50,13 @@ test_expect_success setup '
'
test_expect_success 'reference merge' '
git merge -s recursive -m "reference merge" master
git merge -s recursive -m "reference merge" main
'
PRE_REBASE=$(git rev-parse test-rebase)
test_expect_success rebase '
git checkout test-rebase &&
GIT_TRACE=1 git rebase --merge master
GIT_TRACE=1 git rebase --merge main
'
test_expect_success 'test-rebase@{1} is pre rebase' '
@ -72,24 +75,24 @@ test_expect_success 'merge and rebase should match' '
'
test_expect_success 'rebase the other way' '
git reset --hard master &&
git reset --hard main &&
git rebase --merge side
'
test_expect_success 'rebase -Xtheirs' '
git checkout -b conflicting master~2 &&
git checkout -b conflicting main~2 &&
echo "AB $T" >> original &&
git commit -mconflicting original &&
git rebase -Xtheirs master &&
git rebase -Xtheirs main &&
grep AB original &&
! grep 11 original
'
test_expect_success 'rebase -Xtheirs from orphan' '
git checkout --orphan orphan-conflicting master~2 &&
git checkout --orphan orphan-conflicting main~2 &&
echo "AB $T" >> original &&
git commit -morphan-conflicting original &&
git rebase -Xtheirs master &&
git rebase -Xtheirs main &&
grep AB original &&
! grep 11 original
'
@ -107,9 +110,9 @@ test_expect_success 'merge and rebase should match' '
test_expect_success 'picking rebase' '
git reset --hard side &&
git rebase --merge --onto master side^^ &&
mb=$(git merge-base master HEAD) &&
if test "$mb" = "$(git rev-parse master)"
git rebase --merge --onto main side^^ &&
mb=$(git merge-base main HEAD) &&
if test "$mb" = "$(git rev-parse main)"
then
echo happy
else
@ -140,11 +143,11 @@ test_expect_success 'rebase -s funny -Xopt' '
EOF
chmod +x test-bin/git-merge-funny &&
git reset --hard &&
git checkout -b test-funny master^ &&
git checkout -b test-funny main^ &&
test_commit funny &&
(
PATH=./test-bin:$PATH &&
git rebase -s funny -Xopt master
git rebase -s funny -Xopt main
) &&
test -f funny.was.run
'
@ -165,7 +168,7 @@ test_expect_success 'rebase --skip works with two conflicts in a row' '
test_expect_success '--reapply-cherry-picks' '
git init repo &&
# O(1-10) -- O(1-11) -- O(0-10) master
# O(1-10) -- O(1-11) -- O(0-10) main
# \
# -- O(1-11) -- O(1-12) otherbranch
@ -187,18 +190,18 @@ test_expect_success '--reapply-cherry-picks' '
git -C repo commit -a -m "add 12 in another branch" &&
# Regular rebase fails, because the 1-11 commit is deduplicated
test_must_fail git -C repo rebase --merge master 2> err &&
test_must_fail git -C repo rebase --merge main 2> err &&
test_i18ngrep "error: could not apply.*add 12 in another branch" err &&
git -C repo rebase --abort &&
# With --reapply-cherry-picks, it works
git -C repo rebase --merge --reapply-cherry-picks master
git -C repo rebase --merge --reapply-cherry-picks main
'
test_expect_success '--reapply-cherry-picks refrains from reading unneeded blobs' '
git init server &&
# O(1-10) -- O(1-11) -- O(1-12) master
# O(1-10) -- O(1-11) -- O(1-12) main
# \
# -- O(0-10) otherbranch
@ -220,18 +223,18 @@ test_expect_success '--reapply-cherry-picks refrains from reading unneeded blobs
test_config -C server uploadpack.allowanysha1inwant 1 &&
git clone --filter=blob:none "file://$(pwd)/server" client &&
git -C client checkout origin/master &&
git -C client checkout origin/main &&
git -C client checkout origin/otherbranch &&
# Sanity check to ensure that the blobs from the merge base and "add
# 11" are missing
git -C client rev-list --objects --all --missing=print >missing_list &&
MERGE_BASE_BLOB=$(git -C server rev-parse master^^:file.txt) &&
ADD_11_BLOB=$(git -C server rev-parse master^:file.txt) &&
MERGE_BASE_BLOB=$(git -C server rev-parse main^^:file.txt) &&
ADD_11_BLOB=$(git -C server rev-parse main^:file.txt) &&
grep "[?]$MERGE_BASE_BLOB" missing_list &&
grep "[?]$ADD_11_BLOB" missing_list &&
git -C client rebase --merge --reapply-cherry-picks origin/master &&
git -C client rebase --merge --reapply-cherry-picks origin/main &&
# The blob from the merge base had to be fetched, but not "add 11"
git -C client rev-list --objects --all --missing=print >missing_list &&

View File

@ -5,6 +5,9 @@
test_description='git rebase --merge --skip tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-rebase.sh
@ -48,7 +51,7 @@ test_expect_success setup '
'
test_expect_success 'rebase with git am -3 (default)' '
test_must_fail git rebase master
test_must_fail git rebase main
'
test_expect_success 'rebase --skip can not be used with other options' '
@ -64,7 +67,7 @@ test_expect_success 'rebase moves back to skip-reference' '
test refs/heads/skip-reference = $(git symbolic-ref HEAD) &&
git branch post-rebase &&
git reset --hard pre-rebase &&
test_must_fail git rebase master &&
test_must_fail git rebase main &&
echo "hello" > hello &&
git add hello &&
git rebase --continue &&
@ -75,7 +78,7 @@ test_expect_success 'rebase moves back to skip-reference' '
test_expect_success 'checkout skip-merge' 'git checkout -f skip-merge'
test_expect_success 'rebase with --merge' '
test_must_fail git rebase --merge master
test_must_fail git rebase --merge main
'
test_expect_success 'rebase --skip with --merge' '

View File

@ -25,6 +25,9 @@ Initial setup:
where A, B, D and G all touch file1, and one, two, three, four all
touch file "conflict".
'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-rebase.sh

View File

@ -2,6 +2,9 @@
test_description='rebase should handle arbitrary git message'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-rebase.sh
@ -52,7 +55,7 @@ test_expect_success setup '
git add file3 &&
git commit --allow-empty-message -m "" &&
git checkout master &&
git checkout main &&
echo One >file1 &&
test_tick &&
@ -62,7 +65,7 @@ test_expect_success setup '
test_expect_success 'rebase commit with multi-line subject' '
git rebase master multi-line-subject &&
git rebase main multi-line-subject &&
git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 &&
test_cmp F0 F1 &&
@ -70,14 +73,14 @@ test_expect_success 'rebase commit with multi-line subject' '
'
test_expect_success 'rebase commit with diff in message' '
git rebase master diff-in-message &&
git rebase main diff-in-message &&
git cat-file commit HEAD | sed -e "1,/^$/d" >G1 &&
test_cmp G0 G1 &&
test_cmp G G0
'
test_expect_success 'rebase -m commit with empty message' '
git rebase -m master empty-message-merge
git rebase -m main empty-message-merge
'
test_expect_success 'rebase -i commit with empty message' '

View File

@ -2,6 +2,9 @@
test_description='messages from rebase operation'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success 'setup' '
@ -18,27 +21,27 @@ test_expect_success 'setup' '
'
test_expect_success 'rebase -m' '
git rebase -m master >actual &&
git rebase -m main >actual &&
test_must_be_empty actual
'
test_expect_success 'rebase against master twice' '
git rebase --apply master >out &&
test_expect_success 'rebase against main twice' '
git rebase --apply main >out &&
test_i18ngrep "Current branch topic is up to date" out
'
test_expect_success 'rebase against master twice with --force' '
git rebase --force-rebase --apply master >out &&
test_expect_success 'rebase against main twice with --force' '
git rebase --force-rebase --apply main >out &&
test_i18ngrep "Current branch topic is up to date, rebase forced" out
'
test_expect_success 'rebase against master twice from another branch' '
test_expect_success 'rebase against main twice from another branch' '
git checkout topic^ &&
git rebase --apply master topic >out &&
git rebase --apply main topic >out &&
test_i18ngrep "Current branch topic is up to date" out
'
test_expect_success 'rebase fast-forward to master' '
test_expect_success 'rebase fast-forward to main' '
git checkout topic^ &&
git rebase --apply topic >out &&
test_i18ngrep "Fast-forwarded HEAD to topic" out
@ -46,21 +49,21 @@ test_expect_success 'rebase fast-forward to master' '
test_expect_success 'rebase --stat' '
git reset --hard start &&
git rebase --stat master >diffstat.txt &&
git rebase --stat main >diffstat.txt &&
grep "^ fileX | *1 +$" diffstat.txt
'
test_expect_success 'rebase w/config rebase.stat' '
git reset --hard start &&
git config rebase.stat true &&
git rebase master >diffstat.txt &&
git rebase main >diffstat.txt &&
grep "^ fileX | *1 +$" diffstat.txt
'
test_expect_success 'rebase -n overrides config rebase.stat config' '
git reset --hard start &&
git config rebase.stat true &&
git rebase -n master >diffstat.txt &&
git rebase -n main >diffstat.txt &&
! grep "^ fileX | *1 +$" diffstat.txt
'
@ -113,7 +116,7 @@ test_expect_success 'rebase -i onto unrelated history' '
git init unrelated &&
test_commit -C unrelated 1 &&
git -C unrelated remote add -f origin "$PWD" &&
git -C unrelated branch --set-upstream-to=origin/master &&
git -C unrelated branch --set-upstream-to=origin/main &&
git -C unrelated -c core.editor=true rebase -i -v --stat >actual &&
test_i18ngrep "Changes to " actual &&
test_i18ngrep "5 files changed" actual

View File

@ -2,6 +2,9 @@
test_description='git rebase --abort tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
### Test that we handle space characters properly
@ -37,7 +40,7 @@ testrebase() {
cd "$work_dir" &&
# Clean up the state from the previous one
git reset --hard pre-rebase &&
test_must_fail git rebase$type master &&
test_must_fail git rebase$type main &&
test_path_is_dir "$dotest" &&
git rebase --abort &&
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
@ -48,10 +51,10 @@ testrebase() {
cd "$work_dir" &&
# Clean up the state from the previous one
git reset --hard pre-rebase &&
test_must_fail git rebase$type master &&
test_must_fail git rebase$type main &&
test_path_is_dir "$dotest" &&
test_must_fail git rebase --skip &&
test $(git rev-parse HEAD) = $(git rev-parse master) &&
test $(git rev-parse HEAD) = $(git rev-parse main) &&
git rebase --abort &&
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
test ! -d "$dotest"
@ -61,13 +64,13 @@ testrebase() {
cd "$work_dir" &&
# Clean up the state from the previous one
git reset --hard pre-rebase &&
test_must_fail git rebase$type master &&
test_must_fail git rebase$type main &&
test_path_is_dir "$dotest" &&
echo c > a &&
echo d >> a &&
git add a &&
test_must_fail git rebase --continue &&
test $(git rev-parse HEAD) != $(git rev-parse master) &&
test $(git rev-parse HEAD) != $(git rev-parse main) &&
git rebase --abort &&
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
test ! -d "$dotest"
@ -78,7 +81,7 @@ testrebase() {
# Clean up the state from the previous one
git reset --hard pre-rebase &&
git reflog show to-rebase > reflog_before &&
test_must_fail git rebase$type master &&
test_must_fail git rebase$type main &&
git rebase --abort &&
git reflog show to-rebase > reflog_after &&
test_cmp reflog_before reflog_after &&
@ -89,7 +92,7 @@ testrebase() {
cd "$work_dir" &&
# Clean up the state from the previous one
git reset --hard pre-rebase &&
test_must_fail git rebase$type master &&
test_must_fail git rebase$type main &&
test_must_fail git rebase -v --abort &&
test_must_fail git rebase --abort -v &&
git rebase --abort
@ -103,7 +106,7 @@ test_expect_success 'rebase --apply --quit' '
cd "$work_dir" &&
# Clean up the state from the previous one
git reset --hard pre-rebase &&
test_must_fail git rebase --apply master &&
test_must_fail git rebase --apply main &&
test_path_is_dir .git/rebase-apply &&
head_before=$(git rev-parse HEAD) &&
git rebase --quit &&
@ -115,7 +118,7 @@ test_expect_success 'rebase --merge --quit' '
cd "$work_dir" &&
# Clean up the state from the previous one
git reset --hard pre-rebase &&
test_must_fail git rebase --merge master &&
test_must_fail git rebase --merge main &&
test_path_is_dir .git/rebase-merge &&
head_before=$(git rev-parse HEAD) &&
git rebase --quit &&

View File

@ -2,6 +2,9 @@
test_description='rebasing a commit with multi-line first paragraph.'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '
@ -46,7 +49,7 @@ But otherwise with a sane description." side2 &&
test_expect_success rebase '
git checkout side &&
git rebase master &&
git rebase main &&
git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
git cat-file commit side@{1} | sed -e "1,/^\$/d" >expect &&
test_cmp expect actual

View File

@ -6,6 +6,9 @@ test_description='git rebase -p should preserve merges
Run "git rebase -p" and check that merges are properly carried along
'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
if ! test_have_prereq REBASE_P; then
@ -18,7 +21,7 @@ export GIT_AUTHOR_EMAIL
# Clone 2 (conflicting merge):
#
# A1--A2--B3 <-- origin/master
# A1--A2--B3 <-- origin/main
# \ \
# B1------M <-- topic
# \
@ -26,7 +29,7 @@ export GIT_AUTHOR_EMAIL
#
# Clone 3 (no-ff merge):
#
# A1--A2--B3 <-- origin/master
# A1--A2--B3 <-- origin/main
# \
# B1------M <-- topic
# \ /
@ -44,7 +47,7 @@ test_expect_success 'setup for merge-preserving rebase' \
echo Second > B &&
git add B &&
git commit -m "Add B1" &&
git checkout -f master &&
git checkout -f main &&
echo Third >> A &&
git commit -a -m "Modify A2" &&
echo Fifth > B &&
@ -55,10 +58,10 @@ test_expect_success 'setup for merge-preserving rebase' \
(
cd clone2 &&
git checkout -b topic origin/topic &&
test_must_fail git merge origin/master &&
test_must_fail git merge origin/main &&
echo Resolved >B &&
git add B &&
git commit -m "Merge origin/master into topic"
git commit -m "Merge origin/main into topic"
) &&
git clone ./. clone3 &&

View File

@ -4,6 +4,9 @@ test_description='git rebase --root
Tests if git rebase --root --onto <newparent> can rebase the root commit.
'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
log_with_names () {
@ -24,7 +27,7 @@ test_expect_success 'prepare repository' '
test_expect_success 'rebase --root fails with too many args' '
git checkout -B fail other &&
test_must_fail git rebase --onto master --root fail fail
test_must_fail git rebase --onto main --root fail fail
'
test_expect_success 'setup pre-rebase hook' '
@ -44,7 +47,7 @@ EOF
test_expect_success 'rebase --root --onto <newbase>' '
git checkout -b work other &&
git rebase --root --onto master &&
git rebase --root --onto main &&
git log --pretty=tformat:"%s" > rebased &&
test_cmp expect rebased
'
@ -55,7 +58,7 @@ test_expect_success 'pre-rebase got correct input (1)' '
test_expect_success 'rebase --root --onto <newbase> <branch>' '
git branch work2 other &&
git rebase --root --onto master work2 &&
git rebase --root --onto main work2 &&
git log --pretty=tformat:"%s" > rebased2 &&
test_cmp expect rebased2
'
@ -66,7 +69,7 @@ test_expect_success 'pre-rebase got correct input (2)' '
test_expect_success 'rebase -i --root --onto <newbase>' '
git checkout -b work3 other &&
git rebase -i --root --onto master &&
git rebase -i --root --onto main &&
git log --pretty=tformat:"%s" > rebased3 &&
test_cmp expect rebased3
'
@ -77,7 +80,7 @@ test_expect_success 'pre-rebase got correct input (3)' '
test_expect_success 'rebase -i --root --onto <newbase> <branch>' '
git branch work4 other &&
git rebase -i --root --onto master work4 &&
git rebase -i --root --onto main work4 &&
git log --pretty=tformat:"%s" > rebased4 &&
test_cmp expect rebased4
'
@ -88,7 +91,7 @@ test_expect_success 'pre-rebase got correct input (4)' '
test_expect_success REBASE_P 'rebase -i -p with linear history' '
git checkout -b work5 other &&
git rebase -i -p --root --onto master &&
git rebase -i -p --root --onto main &&
git log --pretty=tformat:"%s" > rebased5 &&
test_cmp expect rebased5
'
@ -122,7 +125,7 @@ EOF
test_expect_success REBASE_P 'rebase -i -p with merge' '
git checkout -b work6 other &&
git rebase -i -p --root --onto master &&
git rebase -i -p --root --onto main &&
log_with_names work6 > rebased6 &&
test_cmp expect-side rebased6
'
@ -157,7 +160,7 @@ EOF
test_expect_success REBASE_P 'rebase -i -p with two roots' '
git checkout -b work7 other &&
git rebase -i -p --root --onto master &&
git rebase -i -p --root --onto main &&
log_with_names work7 > rebased7 &&
test_cmp expect-third rebased7
'
@ -173,14 +176,14 @@ EOF
test_expect_success 'pre-rebase hook stops rebase' '
git checkout -b stops1 other &&
test_must_fail git rebase --root --onto master &&
test_must_fail git rebase --root --onto main &&
test "z$(git symbolic-ref HEAD)" = zrefs/heads/stops1 &&
test 0 = $(git rev-list other...stops1 | wc -l)
'
test_expect_success 'pre-rebase hook stops rebase -i' '
git checkout -b stops2 other &&
test_must_fail git rebase --root --onto master &&
test_must_fail git rebase --root --onto main &&
test "z$(git symbolic-ref HEAD)" = zrefs/heads/stops2 &&
test 0 = $(git rev-list other...stops2 | wc -l)
'
@ -190,7 +193,7 @@ test_expect_success 'remove pre-rebase hook' '
'
test_expect_success 'set up a conflict' '
git checkout master &&
git checkout main &&
echo conflict > B &&
git add B &&
git commit -m conflict
@ -198,7 +201,7 @@ test_expect_success 'set up a conflict' '
test_expect_success 'rebase --root with conflict (first part)' '
git checkout -b conflict1 other &&
test_must_fail git rebase --root --onto master &&
test_must_fail git rebase --root --onto main &&
git ls-files -u | grep "B$"
'
@ -225,7 +228,7 @@ test_expect_success 'rebase --root with conflict (second part)' '
test_expect_success 'rebase -i --root with conflict (first part)' '
git checkout -b conflict2 other &&
test_must_fail git rebase -i --root --onto master &&
test_must_fail git rebase -i --root --onto main &&
git ls-files -u | grep "B$"
'
@ -263,7 +266,7 @@ EOF
test_expect_success REBASE_P 'rebase -i -p --root with conflict (first part)' '
git checkout -b conflict3 other &&
test_must_fail git rebase -i -p --root --onto master &&
test_must_fail git rebase -i -p --root --onto main &&
git ls-files -u | grep "B$"
'

View File

@ -2,6 +2,9 @@
test_description='git rebase with its hook(s)'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '
@ -18,7 +21,7 @@ test_expect_success setup '
git add git &&
test_tick &&
git commit -m side &&
git checkout master &&
git checkout main &&
git log --pretty=oneline --abbrev-commit --graph --all &&
git branch test side
'
@ -26,14 +29,14 @@ test_expect_success setup '
test_expect_success 'rebase' '
git checkout test &&
git reset --hard side &&
git rebase master &&
git rebase main &&
test "z$(cat git)" = zworld
'
test_expect_success 'rebase -i' '
git checkout test &&
git reset --hard side &&
EDITOR=true git rebase -i master &&
EDITOR=true git rebase -i main &&
test "z$(cat git)" = zworld
'
@ -49,53 +52,53 @@ EOF
test_expect_success 'pre-rebase hook gets correct input (1)' '
git checkout test &&
git reset --hard side &&
git rebase master &&
git rebase main &&
test "z$(cat git)" = zworld &&
test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,
test "z$(cat .git/PRE-REBASE-INPUT)" = zmain,
'
test_expect_success 'pre-rebase hook gets correct input (2)' '
git checkout test &&
git reset --hard side &&
git rebase master test &&
git rebase main test &&
test "z$(cat git)" = zworld &&
test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test
test "z$(cat .git/PRE-REBASE-INPUT)" = zmain,test
'
test_expect_success 'pre-rebase hook gets correct input (3)' '
git checkout test &&
git reset --hard side &&
git checkout master &&
git rebase master test &&
git checkout main &&
git rebase main test &&
test "z$(cat git)" = zworld &&
test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test
test "z$(cat .git/PRE-REBASE-INPUT)" = zmain,test
'
test_expect_success 'pre-rebase hook gets correct input (4)' '
git checkout test &&
git reset --hard side &&
EDITOR=true git rebase -i master &&
EDITOR=true git rebase -i main &&
test "z$(cat git)" = zworld &&
test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,
test "z$(cat .git/PRE-REBASE-INPUT)" = zmain,
'
test_expect_success 'pre-rebase hook gets correct input (5)' '
git checkout test &&
git reset --hard side &&
EDITOR=true git rebase -i master test &&
EDITOR=true git rebase -i main test &&
test "z$(cat git)" = zworld &&
test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test
test "z$(cat .git/PRE-REBASE-INPUT)" = zmain,test
'
test_expect_success 'pre-rebase hook gets correct input (6)' '
git checkout test &&
git reset --hard side &&
git checkout master &&
EDITOR=true git rebase -i master test &&
git checkout main &&
EDITOR=true git rebase -i main test &&
test "z$(cat git)" = zworld &&
test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test
test "z$(cat .git/PRE-REBASE-INPUT)" = zmain,test
'
test_expect_success 'setup pre-rebase hook that fails' '
@ -110,7 +113,7 @@ EOF
test_expect_success 'pre-rebase hook stops rebase (1)' '
git checkout test &&
git reset --hard side &&
test_must_fail git rebase master &&
test_must_fail git rebase main &&
test "z$(git symbolic-ref HEAD)" = zrefs/heads/test &&
test 0 = $(git rev-list HEAD...side | wc -l)
'
@ -118,7 +121,7 @@ test_expect_success 'pre-rebase hook stops rebase (1)' '
test_expect_success 'pre-rebase hook stops rebase (2)' '
git checkout test &&
git reset --hard side &&
test_must_fail env EDITOR=: git rebase -i master &&
test_must_fail env EDITOR=: git rebase -i main &&
test "z$(git symbolic-ref HEAD)" = zrefs/heads/test &&
test 0 = $(git rev-list HEAD...side | wc -l)
'
@ -126,7 +129,7 @@ test_expect_success 'pre-rebase hook stops rebase (2)' '
test_expect_success 'rebase --no-verify overrides pre-rebase (1)' '
git checkout test &&
git reset --hard side &&
git rebase --no-verify master &&
git rebase --no-verify main &&
test "z$(git symbolic-ref HEAD)" = zrefs/heads/test &&
test "z$(cat git)" = zworld
'
@ -134,7 +137,7 @@ test_expect_success 'rebase --no-verify overrides pre-rebase (1)' '
test_expect_success 'rebase --no-verify overrides pre-rebase (2)' '
git checkout test &&
git reset --hard side &&
EDITOR=true git rebase --no-verify -i master &&
EDITOR=true git rebase --no-verify -i main &&
test "z$(git symbolic-ref HEAD)" = zrefs/heads/test &&
test "z$(cat git)" = zworld
'

View File

@ -2,6 +2,9 @@
test_description='auto squash'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-rebase.sh
@ -407,7 +410,7 @@ test_expect_success 'wrapped original subject' '
test_expect_success 'abort last squash' '
test_when_finished "test_might_fail git rebase --abort" &&
test_when_finished "git checkout master" &&
test_when_finished "git checkout main" &&
git checkout -b some-squashes &&
git commit --allow-empty -m first &&

View File

@ -2,17 +2,20 @@
test_description='git rebase --onto A...B'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY/lib-rebase.sh"
# Rebase only the tip commit of "topic" on merge base between "master"
# and "topic". Cannot do this for "side" with "master" because there
# Rebase only the tip commit of "topic" on merge base between "main"
# and "topic". Cannot do this for "side" with "main" because there
# is no single merge base.
#
#
# F---G topic G'
# / /
# A---B---C---D---E master --> A---B---C---D---E
# A---B---C---D---E main --> A---B---C---D---E
# \ \ /
# \ x
# \ / \
@ -26,7 +29,7 @@ test_expect_success setup '
git branch topic &&
git checkout side &&
test_commit H &&
git checkout master &&
git checkout main &&
test_tick &&
git merge H &&
git tag D &&
@ -42,83 +45,83 @@ test_expect_success setup '
test_commit K
'
test_expect_success 'rebase --onto master...topic' '
test_expect_success 'rebase --onto main...topic' '
git reset --hard &&
git checkout topic &&
git reset --hard G &&
git rebase --onto master...topic F &&
git rebase --onto main...topic F &&
git rev-parse HEAD^1 >actual &&
git rev-parse C^0 >expect &&
test_cmp expect actual
'
test_expect_success 'rebase --onto master...' '
test_expect_success 'rebase --onto main...' '
git reset --hard &&
git checkout topic &&
git reset --hard G &&
git rebase --onto master... F &&
git rebase --onto main... F &&
git rev-parse HEAD^1 >actual &&
git rev-parse C^0 >expect &&
test_cmp expect actual
'
test_expect_success 'rebase --onto master...side' '
test_expect_success 'rebase --onto main...side' '
git reset --hard &&
git checkout side &&
git reset --hard K &&
test_must_fail git rebase --onto master...side J
test_must_fail git rebase --onto main...side J
'
test_expect_success 'rebase -i --onto master...topic' '
test_expect_success 'rebase -i --onto main...topic' '
git reset --hard &&
git checkout topic &&
git reset --hard G &&
set_fake_editor &&
EXPECT_COUNT=1 git rebase -i --onto master...topic F &&
EXPECT_COUNT=1 git rebase -i --onto main...topic F &&
git rev-parse HEAD^1 >actual &&
git rev-parse C^0 >expect &&
test_cmp expect actual
'
test_expect_success 'rebase -i --onto master...' '
test_expect_success 'rebase -i --onto main...' '
git reset --hard &&
git checkout topic &&
git reset --hard G &&
set_fake_editor &&
EXPECT_COUNT=1 git rebase -i --onto master... F &&
EXPECT_COUNT=1 git rebase -i --onto main... F &&
git rev-parse HEAD^1 >actual &&
git rev-parse C^0 >expect &&
test_cmp expect actual
'
test_expect_success 'rebase -i --onto master...side' '
test_expect_success 'rebase -i --onto main...side' '
git reset --hard &&
git checkout side &&
git reset --hard K &&
set_fake_editor &&
test_must_fail git rebase -i --onto master...side J
test_must_fail git rebase -i --onto main...side J
'
test_expect_success 'rebase --keep-base --onto incompatible' '
test_must_fail git rebase --keep-base --onto master...
test_must_fail git rebase --keep-base --onto main...
'
test_expect_success 'rebase --keep-base --root incompatible' '
test_must_fail git rebase --keep-base --root
'
test_expect_success 'rebase --keep-base master from topic' '
test_expect_success 'rebase --keep-base main from topic' '
git reset --hard &&
git checkout topic &&
git reset --hard G &&
git rebase --keep-base master &&
git rebase --keep-base main &&
git rev-parse C >base.expect &&
git merge-base master HEAD >base.actual &&
git merge-base main HEAD >base.actual &&
test_cmp base.expect base.actual &&
git rev-parse HEAD~2 >actual &&
@ -126,23 +129,23 @@ test_expect_success 'rebase --keep-base master from topic' '
test_cmp expect actual
'
test_expect_success 'rebase --keep-base master from side' '
test_expect_success 'rebase --keep-base main from side' '
git reset --hard &&
git checkout side &&
git reset --hard K &&
test_must_fail git rebase --keep-base master
test_must_fail git rebase --keep-base main
'
test_expect_success 'rebase -i --keep-base master from topic' '
test_expect_success 'rebase -i --keep-base main from topic' '
git reset --hard &&
git checkout topic &&
git reset --hard G &&
set_fake_editor &&
EXPECT_COUNT=2 git rebase -i --keep-base master &&
EXPECT_COUNT=2 git rebase -i --keep-base main &&
git rev-parse C >base.expect &&
git merge-base master HEAD >base.actual &&
git merge-base main HEAD >base.actual &&
test_cmp base.expect base.actual &&
git rev-parse HEAD~2 >actual &&
@ -150,13 +153,13 @@ test_expect_success 'rebase -i --keep-base master from topic' '
test_cmp expect actual
'
test_expect_success 'rebase -i --keep-base master from side' '
test_expect_success 'rebase -i --keep-base main from side' '
git reset --hard &&
git checkout side &&
git reset --hard K &&
set_fake_editor &&
test_must_fail git rebase -i --keep-base master
test_must_fail git rebase -i --keep-base main
'
test_done

View File

@ -2,6 +2,9 @@
test_description='git rebase --continue tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-rebase.sh
@ -15,13 +18,13 @@ test_expect_success 'setup' '
git checkout -b topic HEAD^ &&
test_commit "commit-new-file-F2-on-topic-branch" F2 22 &&
git checkout master
git checkout main
'
test_expect_success 'interactive rebase --continue works with touched file' '
rm -fr .git/rebase-* &&
git reset --hard &&
git checkout master &&
git checkout main &&
FAKE_LINES="edit 1" git rebase -i HEAD^ &&
test-tool chmtime =-60 F1 &&
@ -31,9 +34,9 @@ test_expect_success 'interactive rebase --continue works with touched file' '
test_expect_success 'non-interactive rebase --continue works with touched file' '
rm -fr .git/rebase-* &&
git reset --hard &&
git checkout master &&
git checkout main &&
test_must_fail git rebase --onto master master topic &&
test_must_fail git rebase --onto main main topic &&
echo "Resolved" >F2 &&
git add F2 &&
test-tool chmtime =-60 F1 &&
@ -61,7 +64,7 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
chmod +x test-bin/git-merge-funny &&
(
PATH=./test-bin:$PATH &&
test_must_fail git rebase -s funny -Xopt master topic
test_must_fail git rebase -s funny -Xopt main topic
) &&
test -f funny.was.run &&
rm funny.was.run &&
@ -93,7 +96,7 @@ test_expect_success 'rebase -i --continue handles merge strategy and options' '
chmod +x test-bin/git-merge-funny &&
(
PATH=./test-bin:$PATH &&
test_must_fail git rebase -i -s funny -Xopt -Xfoo master topic
test_must_fail git rebase -i -s funny -Xopt -Xfoo main topic
) &&
test -f funny.was.run &&
rm funny.was.run &&
@ -188,11 +191,11 @@ test_expect_success '--skip after failed fixup cleans commit message' '
test_expect_success 'setup rerere database' '
rm -fr .git/rebase-* &&
git reset --hard commit-new-file-F3-on-topic-branch &&
git checkout master &&
git checkout main &&
test_commit "commit-new-file-F3" F3 3 &&
test_config rerere.enabled true &&
git update-ref refs/heads/topic commit-new-file-F3-on-topic-branch &&
test_must_fail git rebase -m master topic &&
test_must_fail git rebase -m main topic &&
echo "Resolved" >F2 &&
cp F2 expected-F2 &&
git add F2 &&
@ -207,7 +210,7 @@ test_expect_success 'setup rerere database' '
prepare () {
rm -fr .git/rebase-* &&
git reset --hard commit-new-file-F3-on-topic-branch &&
git checkout master &&
git checkout main &&
test_config rerere.enabled true
}
@ -215,7 +218,7 @@ test_rerere_autoupdate () {
action=$1 &&
test_expect_success "rebase $action --continue remembers --rerere-autoupdate" '
prepare &&
test_must_fail git rebase $action --rerere-autoupdate master topic &&
test_must_fail git rebase $action --rerere-autoupdate main topic &&
test_cmp expected-F2 F2 &&
git diff-files --quiet &&
test_must_fail git rebase --continue &&
@ -227,7 +230,7 @@ test_rerere_autoupdate () {
test_expect_success "rebase $action --continue honors rerere.autoUpdate" '
prepare &&
test_config rerere.autoupdate true &&
test_must_fail git rebase $action master topic &&
test_must_fail git rebase $action main topic &&
test_cmp expected-F2 F2 &&
git diff-files --quiet &&
test_must_fail git rebase --continue &&
@ -239,7 +242,7 @@ test_rerere_autoupdate () {
test_expect_success "rebase $action --continue remembers --no-rerere-autoupdate" '
prepare &&
test_config rerere.autoupdate true &&
test_must_fail git rebase $action --no-rerere-autoupdate master topic &&
test_must_fail git rebase $action --no-rerere-autoupdate main topic &&
test_cmp expected-F2 F2 &&
test_must_fail git diff-files --quiet &&
git add F2 &&

View File

@ -2,6 +2,9 @@
test_description='git rebase - test patch id computation'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
scramble () {
@ -24,7 +27,7 @@ test_expect_success 'setup' '
test_expect_success 'setup: 500 lines' '
rm -f .gitattributes &&
git checkout -q -f master &&
git checkout -q -f main &&
git reset --hard root &&
test_seq 500 >file &&
git add file &&
@ -40,7 +43,7 @@ test_expect_success 'setup: 500 lines' '
git add newfile &&
git commit -q -m "add small file" &&
git cherry-pick master >/dev/null 2>&1
git cherry-pick main >/dev/null 2>&1
'
test_expect_success 'setup attributes' '
@ -48,18 +51,18 @@ test_expect_success 'setup attributes' '
'
test_expect_success 'detect upstream patch' '
git checkout -q master &&
git checkout -q main &&
scramble file &&
git add file &&
git commit -q -m "change big file again" &&
git checkout -q other^{} &&
git rebase master &&
git rev-list master...HEAD~ >revs &&
git rebase main &&
git rev-list main...HEAD~ >revs &&
test_must_be_empty revs
'
test_expect_success 'do not drop patch' '
git branch -f squashed master &&
git branch -f squashed main &&
git checkout -q -f squashed &&
git reset -q --soft HEAD~2 &&
git commit -q -m squashed &&

View File

@ -4,6 +4,9 @@
#
test_description='git rebase --autostash tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '
@ -21,12 +24,12 @@ test_expect_success setup '
git add . &&
test_tick &&
git commit -m "third commit" &&
git checkout -b unrelated-onto-branch master &&
git checkout -b unrelated-onto-branch main &&
echo unrelated >file4 &&
git add . &&
test_tick &&
git commit -m "unrelated commit" &&
git checkout -b related-onto-branch master &&
git checkout -b related-onto-branch main &&
echo conflicting-change >file2 &&
git add . &&
test_tick &&
@ -305,7 +308,7 @@ test_expect_success 'autostash is saved on editor failure with conflict' '
'
test_expect_success 'autostash with dirty submodules' '
test_when_finished "git reset --hard && git checkout master" &&
test_when_finished "git reset --hard && git checkout main" &&
git checkout -b with-submodule &&
git submodule add ./ sub &&
test_tick &&
@ -324,7 +327,7 @@ test_expect_success 'branch is left alone when possible' '
test_expect_success 'never change active branch' '
git checkout -b not-the-feature-branch unrelated-onto-branch &&
test_when_finished "git reset --hard && git checkout master" &&
test_when_finished "git reset --hard && git checkout main" &&
echo changed >file0 &&
git rebase --autostash not-the-feature-branch feature-branch &&
test_cmp_rev not-the-feature-branch unrelated-onto-branch

View File

@ -7,7 +7,7 @@ test_description='git rebase interactive with rewording'
. "$TEST_DIRECTORY"/lib-rebase.sh
test_expect_success 'setup' '
test_commit master file-1 test &&
test_commit main file-1 test &&
git checkout -b stuff &&
@ -22,7 +22,7 @@ test_expect_success 'reword without issues functions as intended' '
set_fake_editor &&
FAKE_LINES="pick 1 reword 2" FAKE_COMMIT_MESSAGE="feature_b_reworded" \
git rebase -i -v master &&
git rebase -i -v main &&
test "$(git log -1 --format=%B)" = "feature_b_reworded" &&
test $(git rev-list --count HEAD) = 3
@ -35,7 +35,7 @@ test_expect_success 'reword after a conflict preserves commit' '
set_fake_editor &&
test_must_fail env FAKE_LINES="reword 2" \
git rebase -i -v master &&
git rebase -i -v main &&
git checkout --theirs file-2 &&
git add file-2 &&

View File

@ -4,6 +4,9 @@ test_description='git rebase tests for -Xsubtree
This test runs git rebase and tests the subtree strategy.
'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-rebase.sh
@ -17,7 +20,7 @@ commit_message() {
#
# topic_1 - topic_2 - topic_3
# \
# README ---------------------- Add subproject master - topic_4 - files_subtree/topic_5
# README ---------------------- Add subproject main - topic_4 - files_subtree/topic_5
#
# Where the merge moves the files topic_[123].t into the subdirectory
# files_subtree/ and topic_4 as well as files_subtree/topic_5 add files to that
@ -28,7 +31,7 @@ commit_message() {
# an empty commit is added on top. The pre-rebase commit history looks like
# this:
#
# Add subproject master - topic_4 - files_subtree/topic_5 - Empty commit
# Add subproject main - topic_4 - files_subtree/topic_5 - Empty commit
#
# where the root commit adds three files: topic_1.t, topic_2.t and topic_3.t.
#
@ -48,11 +51,11 @@ test_expect_success 'setup' '
test_commit -C files topic_3 &&
: perform subtree merge into files_subtree/ &&
git fetch files refs/heads/master:refs/heads/files-master &&
git fetch files refs/heads/main:refs/heads/files-main &&
git merge -s ours --no-commit --allow-unrelated-histories \
files-master &&
git read-tree --prefix=files_subtree -u files-master &&
git commit -m "Add subproject master" &&
files-main &&
git read-tree --prefix=files_subtree -u files-main &&
git commit -m "Add subproject main" &&
: add two extra commits to rebase &&
test_commit -C files_subtree topic_4 &&
@ -70,7 +73,7 @@ test_expect_success 'setup' '
test_expect_failure REBASE_P 'Rebase -Xsubtree --preserve-merges --onto commit' '
reset_rebase &&
git checkout -b rebase-preserve-merges to-rebase &&
git rebase -Xsubtree=files_subtree --preserve-merges --onto files-master master &&
git rebase -Xsubtree=files_subtree --preserve-merges --onto files-main main &&
verbose test "$(commit_message HEAD~)" = "topic_4" &&
verbose test "$(commit_message HEAD)" = "files_subtree/topic_5"
'
@ -79,7 +82,7 @@ test_expect_failure REBASE_P 'Rebase -Xsubtree --preserve-merges --onto commit'
test_expect_failure REBASE_P 'Rebase -Xsubtree --keep-empty --preserve-merges --onto commit' '
reset_rebase &&
git checkout -b rebase-keep-empty to-rebase &&
git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-master master &&
git rebase -Xsubtree=files_subtree --keep-empty --preserve-merges --onto files-main main &&
verbose test "$(commit_message HEAD~2)" = "topic_4" &&
verbose test "$(commit_message HEAD~)" = "files_subtree/topic_5" &&
verbose test "$(commit_message HEAD)" = "Empty commit"
@ -88,7 +91,7 @@ test_expect_failure REBASE_P 'Rebase -Xsubtree --keep-empty --preserve-merges --
test_expect_success 'Rebase -Xsubtree --empty=ask --onto commit' '
reset_rebase &&
git checkout -b rebase-onto to-rebase &&
test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --onto files-master master &&
test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --onto files-main main &&
: first pick results in no changes &&
git rebase --skip &&
verbose test "$(commit_message HEAD~2)" = "topic_4" &&
@ -99,7 +102,7 @@ test_expect_success 'Rebase -Xsubtree --empty=ask --onto commit' '
test_expect_success 'Rebase -Xsubtree --empty=ask --rebase-merges --onto commit' '
reset_rebase &&
git checkout -b rebase-merges-onto to-rebase &&
test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --rebase-merges --onto files-master --root &&
test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --rebase-merges --onto files-main --root &&
: first pick results in no changes &&
git rebase --skip &&
verbose test "$(commit_message HEAD~2)" = "topic_4" &&

Some files were not shown because too many files have changed in this diff Show More