t5[0-4]*: adjust the references to the default branch name "main"

Carefully excluding t5310, which is developed independently of the
current patch series at the time of writing, we now use `main` as
default branch in t5[0-4]*. This trick was performed via

	$ (cd t &&
	   sed -i -e 's/master/main/g' -e 's/MASTER/MAIN/g' \
		-e 's/Master/Main/g' -- t5[0-4]*.sh &&
	   git checkout HEAD -- t5310\*)

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Johannes Schindelin 2020-11-18 23:44:29 +00:00 committed by Junio C Hamano
parent 4b071211e6
commit 966b4be276
15 changed files with 131 additions and 131 deletions

View File

@ -2,7 +2,7 @@


test_description='Test workflows involving pull request.' test_description='Test workflows involving pull request.'


GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -34,13 +34,13 @@ test_expect_success 'setup' '
test_tick && test_tick &&
git commit -m "\"Thirty days\", a reminder of month lengths" && git commit -m "\"Thirty days\", a reminder of month lengths" &&
git tag -m "version 1" -a initial && git tag -m "version 1" -a initial &&
git push --tags origin master git push --tags origin main
) && ) &&
( (
cd local && cd local &&
git remote add upstream "$trash_url/upstream.git" && git remote add upstream "$trash_url/upstream.git" &&
git fetch upstream && git fetch upstream &&
git pull upstream master && git pull upstream main &&
cat <<-\EOT >>mnemonic.txt && cat <<-\EOT >>mnemonic.txt &&
Of twyecescore-eightt is but eine, Of twyecescore-eightt is but eine,
And all the remnante be thrycescore-eine. And all the remnante be thrycescore-eine.
@ -62,7 +62,7 @@ test_expect_success 'setup' '
git commit -a -m "Adapt to use modern, simpler English git commit -a -m "Adapt to use modern, simpler English


But keep the old version, too, in case some people prefer it." && But keep the old version, too, in case some people prefer it." &&
git checkout master git checkout main
) )


' '
@ -132,7 +132,7 @@ test_expect_success 'pull request when forgot to push' '
( (
cd local && cd local &&
git checkout initial && git checkout initial &&
git merge --ff-only master && git merge --ff-only main &&
test_must_fail git request-pull initial "$downstream_url" \ test_must_fail git request-pull initial "$downstream_url" \
2>../err 2>../err
) && ) &&
@ -148,9 +148,9 @@ test_expect_success 'pull request after push' '
( (
cd local && cd local &&
git checkout initial && git checkout initial &&
git merge --ff-only master && git merge --ff-only main &&
git push origin master:for-upstream && git push origin main:for-upstream &&
git request-pull initial origin master:for-upstream >../request git request-pull initial origin main:for-upstream >../request
) && ) &&
sed -nf read-request.sed <request >digest && sed -nf read-request.sed <request >digest &&
{ {
@ -175,9 +175,9 @@ test_expect_success 'request asks HEAD to be pulled' '
( (
cd local && cd local &&
git checkout initial && git checkout initial &&
git merge --ff-only master && git merge --ff-only main &&
git push --tags origin master simplify && git push --tags origin main simplify &&
git push origin master:for-upstream && git push origin main:for-upstream &&
git request-pull initial "$downstream_url" >../request git request-pull initial "$downstream_url" >../request
) && ) &&
sed -nf read-request.sed <request >digest && sed -nf read-request.sed <request >digest &&
@ -218,7 +218,7 @@ test_expect_success 'pull request format' '
( (
cd local && cd local &&
git checkout initial && git checkout initial &&
git merge --ff-only master && git merge --ff-only main &&
git push origin tags/full && git push origin tags/full &&
git request-pull initial "$downstream_url" tags/full >../request git request-pull initial "$downstream_url" tags/full >../request
) && ) &&
@ -246,9 +246,9 @@ test_expect_success 'request-pull ignores OPTIONS_KEEPDASHDASH poison' '
OPTIONS_KEEPDASHDASH=Yes && OPTIONS_KEEPDASHDASH=Yes &&
export OPTIONS_KEEPDASHDASH && export OPTIONS_KEEPDASHDASH &&
git checkout initial && git checkout initial &&
git merge --ff-only master && git merge --ff-only main &&
git push origin master:for-upstream && git push origin main:for-upstream &&
git request-pull -- initial "$downstream_url" master:for-upstream >../request git request-pull -- initial "$downstream_url" main:for-upstream >../request
) )


' '
@ -260,7 +260,7 @@ test_expect_success 'request-pull quotes regex metacharacters properly' '
( (
cd local && cd local &&
git checkout initial && git checkout initial &&
git merge --ff-only master && git merge --ff-only main &&
git tag -mrelease v2.0 && git tag -mrelease v2.0 &&
git push origin refs/tags/v2.0:refs/tags/v2-0 && git push origin refs/tags/v2.0:refs/tags/v2-0 &&
test_must_fail git request-pull initial "$downstream_url" tags/v2.0 \ test_must_fail git request-pull initial "$downstream_url" tags/v2.0 \
@ -278,7 +278,7 @@ test_expect_success 'pull request with mismatched object' '
( (
cd local && cd local &&
git checkout initial && git checkout initial &&
git merge --ff-only master && git merge --ff-only main &&
git push origin HEAD:refs/tags/full && git push origin HEAD:refs/tags/full &&
test_must_fail git request-pull initial "$downstream_url" tags/full \ test_must_fail git request-pull initial "$downstream_url" tags/full \
2>../err 2>../err
@ -295,7 +295,7 @@ test_expect_success 'pull request with stale object' '
( (
cd local && cd local &&
git checkout initial && git checkout initial &&
git merge --ff-only master && git merge --ff-only main &&
git push origin refs/tags/full && git push origin refs/tags/full &&
git tag -f -m"Thirty-one days" full && git tag -f -m"Thirty-one days" full &&
test_must_fail git request-pull initial "$downstream_url" tags/full \ test_must_fail git request-pull initial "$downstream_url" tags/full \

View File

@ -4,7 +4,7 @@
# #


test_description='prune' test_description='prune'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -122,7 +122,7 @@ test_expect_success 'prune: do not prune detached HEAD with no reflog' '
test_expect_success 'prune: prune former HEAD after checking out branch' ' test_expect_success 'prune: prune former HEAD after checking out branch' '


head_oid=$(git rev-parse HEAD) && head_oid=$(git rev-parse HEAD) &&
git checkout --quiet master && git checkout --quiet main &&
git prune -v >prune_actual && git prune -v >prune_actual &&
grep "$head_oid" prune_actual grep "$head_oid" prune_actual



View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh


test_description='git pack-object --include-tag' test_description='git pack-object --include-tag'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -114,7 +114,7 @@ test_expect_success 'check unpacked result (have all objects)' '


test_expect_success 'single-branch clone can transfer tag' ' test_expect_success 'single-branch clone can transfer tag' '
rm -rf clone.git && rm -rf clone.git &&
git clone --no-local --single-branch -b master . clone.git && git clone --no-local --single-branch -b main . clone.git &&
git -C clone.git fsck git -C clone.git fsck
' '



View File

@ -8,7 +8,7 @@ bail out or to proceed using it as a reachable tip, but it is _not_
OK to proceed as if it did not exist. Otherwise we might silently OK to proceed as if it did not exist. Otherwise we might silently
delete objects that cannot be recovered. delete objects that cannot be recovered.
' '
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -19,7 +19,7 @@ test_expect_success 'disable reflogs' '
' '


test_expect_success 'create history reachable only from a bogus-named ref' ' test_expect_success 'create history reachable only from a bogus-named ref' '
test_tick && git commit --allow-empty -m master && test_tick && git commit --allow-empty -m main &&
base=$(git rev-parse HEAD) && base=$(git rev-parse HEAD) &&
test_tick && git commit --allow-empty -m bogus && test_tick && git commit --allow-empty -m bogus &&
bogus=$(git rev-parse HEAD) && bogus=$(git rev-parse HEAD) &&
@ -54,7 +54,7 @@ test_expect_success 'clean up bogus ref' '
' '


# We create two new objects here, "one" and "two". Our # We create two new objects here, "one" and "two". Our
# master branch points to "two", which is deleted, # main branch points to "two", which is deleted,
# corrupting the repository. But we'd like to make sure # corrupting the repository. But we'd like to make sure
# that the otherwise unreachable "one" is not pruned # that the otherwise unreachable "one" is not pruned
# (since it is the user's best bet for recovering # (since it is the user's best bet for recovering
@ -84,7 +84,7 @@ test_expect_success 'pruning with a corrupted tip does not drop history' '
test_expect_success 'pack-refs does not silently delete broken loose ref' ' test_expect_success 'pack-refs does not silently delete broken loose ref' '
git pack-refs --all --prune && git pack-refs --all --prune &&
echo $missing >expect && echo $missing >expect &&
git rev-parse refs/heads/master >actual && git rev-parse refs/heads/main >actual &&
test_cmp expect actual test_cmp expect actual
' '


@ -92,25 +92,25 @@ test_expect_success 'pack-refs does not silently delete broken loose ref' '
# actually pack it, as it is perfectly reasonable to # actually pack it, as it is perfectly reasonable to
# skip processing a broken ref # skip processing a broken ref
test_expect_success 'create packed-refs file with broken ref' ' test_expect_success 'create packed-refs file with broken ref' '
rm -f .git/refs/heads/master && rm -f .git/refs/heads/main &&
cat >.git/packed-refs <<-EOF && cat >.git/packed-refs <<-EOF &&
$missing refs/heads/master $missing refs/heads/main
$recoverable refs/heads/other $recoverable refs/heads/other
EOF EOF
echo $missing >expect && echo $missing >expect &&
git rev-parse refs/heads/master >actual && git rev-parse refs/heads/main >actual &&
test_cmp expect actual test_cmp expect actual
' '


test_expect_success 'pack-refs does not silently delete broken packed ref' ' test_expect_success 'pack-refs does not silently delete broken packed ref' '
git pack-refs --all --prune && git pack-refs --all --prune &&
git rev-parse refs/heads/master >actual && git rev-parse refs/heads/main >actual &&
test_cmp expect actual test_cmp expect actual
' '


test_expect_success 'pack-refs does not drop broken refs during deletion' ' test_expect_success 'pack-refs does not drop broken refs during deletion' '
git update-ref -d refs/heads/other && git update-ref -d refs/heads/other &&
git rev-parse refs/heads/master >actual && git rev-parse refs/heads/main >actual &&
test_cmp expect actual test_cmp expect actual
' '



View File

@ -2,7 +2,7 @@


test_description='git pack-objects using object filtering' test_description='git pack-objects using object filtering'


GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -385,7 +385,7 @@ test_expect_success 'verify sparse:oid=oid-ish' '
awk -f print_2.awk ls_files_result | awk -f print_2.awk ls_files_result |
sort >expected && sort >expected &&


git -C r4 pack-objects --revs --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF && git -C r4 pack-objects --revs --stdout --filter=sparse:oid=main:pattern >filter.pack <<-EOF &&
HEAD HEAD
EOF EOF
git -C r4 index-pack ../filter.pack && git -C r4 index-pack ../filter.pack &&

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh


test_description='pack-objects object selection using sparse algorithm' test_description='pack-objects object selection using sparse algorithm'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -21,7 +21,7 @@ test_expect_success 'setup repo' '
git commit -m "Initialized trees" && git commit -m "Initialized trees" &&
for i in $(test_seq 1 3) for i in $(test_seq 1 3)
do do
git checkout -b topic$i master && git checkout -b topic$i main &&
echo change-$i >f$i/f$i/data.txt && echo change-$i >f$i/f$i/data.txt &&
git commit -a -m "Changed f$i/f$i/data.txt" git commit -a -m "Changed f$i/f$i/data.txt"
done && done &&

View File

@ -6,7 +6,7 @@
test_description='Test git pack-redundant test_description='Test git pack-redundant


In order to test git-pack-redundant, we will create a number of objects and In order to test git-pack-redundant, we will create a number of objects and
packs in the repository `master.git`. The relationship between packs (P1-P8) packs in the repository `main.git`. The relationship between packs (P1-P8)
and objects (T, A-R) is showed in the following chart. Objects of a pack will and objects (T, A-R) is showed in the following chart. Objects of a pack will
be marked with letter x, while objects of redundant packs will be marked with be marked with letter x, while objects of redundant packs will be marked with
exclamation point, and redundant pack itself will be marked with asterisk. exclamation point, and redundant pack itself will be marked with asterisk.
@ -25,7 +25,7 @@ exclamation point, and redundant pack itself will be marked with asterisk.
ALL | x x x x x x x x x x x x x x x x x x x ALL | x x x x x x x x x x x x x x x x x x x


Another repository `shared.git` has unique objects (X-Z), while other objects Another repository `shared.git` has unique objects (X-Z), while other objects
(marked with letter s) are shared through alt-odb (of `master.git`). The (marked with letter s) are shared through alt-odb (of `main.git`). The
relationship between packs and objects is as follows: relationship between packs and objects is as follows:


| T A B C D E F G H I J K L M N O P Q R X Y Z | T A B C D E F G H I J K L M N O P Q R X Y Z
@ -36,7 +36,7 @@ relationship between packs and objects is as follows:


. ./test-lib.sh . ./test-lib.sh


master_repo=master.git main_repo=main.git
shared_repo=shared.git shared_repo=shared.git


# Create commits in <repo> and assign each commit's oid to shell variables # Create commits in <repo> and assign each commit's oid to shell variables
@ -69,7 +69,7 @@ create_commits_in () {
shift || shift ||
return 1 return 1
done && done &&
git -C "$repo" update-ref refs/heads/master $oid git -C "$repo" update-ref refs/heads/main $oid
} }


# Create pack in <repo> and assign pack id to variable given in the 2nd argument # Create pack in <repo> and assign pack id to variable given in the 2nd argument
@ -107,9 +107,9 @@ format_packfiles () {
sort sort
} }


test_expect_success 'setup master repo' ' test_expect_success 'setup main repo' '
git init --bare "$master_repo" && git init --bare "$main_repo" &&
create_commits_in "$master_repo" A B C D E F G H I J K L M N O P Q R create_commits_in "$main_repo" A B C D E F G H I J K L M N O P Q R
' '


############################################################################# #############################################################################
@ -124,8 +124,8 @@ test_expect_success 'setup master repo' '
# ALL | x x x x x x x x x x x x x x x # ALL | x x x x x x x x x x x x x x x
# #
############################################################################# #############################################################################
test_expect_success 'master: no redundant for pack 1, 2, 3' ' test_expect_success 'main: no redundant for pack 1, 2, 3' '
create_pack_in "$master_repo" P1 <<-EOF && create_pack_in "$main_repo" P1 <<-EOF &&
$T $T
$A $A
$B $B
@ -135,7 +135,7 @@ test_expect_success 'master: no redundant for pack 1, 2, 3' '
$F $F
$R $R
EOF EOF
create_pack_in "$master_repo" P2 <<-EOF && create_pack_in "$main_repo" P2 <<-EOF &&
$B $B
$C $C
$D $D
@ -144,7 +144,7 @@ test_expect_success 'master: no redundant for pack 1, 2, 3' '
$H $H
$I $I
EOF EOF
create_pack_in "$master_repo" P3 <<-EOF && create_pack_in "$main_repo" P3 <<-EOF &&
$F $F
$I $I
$J $J
@ -153,7 +153,7 @@ test_expect_success 'master: no redundant for pack 1, 2, 3' '
$M $M
EOF EOF
( (
cd "$master_repo" && cd "$main_repo" &&
git pack-redundant --all >out && git pack-redundant --all >out &&
test_must_be_empty out test_must_be_empty out
) )
@ -173,22 +173,22 @@ test_expect_success 'master: no redundant for pack 1, 2, 3' '
# ALL | x x x x x x x x x x x x x x x x x x # ALL | x x x x x x x x x x x x x x x x x x
# #
############################################################################# #############################################################################
test_expect_success 'master: one of pack-2/pack-3 is redundant' ' test_expect_success 'main: one of pack-2/pack-3 is redundant' '
create_pack_in "$master_repo" P4 <<-EOF && create_pack_in "$main_repo" P4 <<-EOF &&
$J $J
$K $K
$L $L
$M $M
$P $P
EOF EOF
create_pack_in "$master_repo" P5 <<-EOF && create_pack_in "$main_repo" P5 <<-EOF &&
$G $G
$H $H
$N $N
$O $O
EOF EOF
( (
cd "$master_repo" && cd "$main_repo" &&
cat >expect <<-EOF && cat >expect <<-EOF &&
P3:$P3 P3:$P3
EOF EOF
@ -214,18 +214,18 @@ test_expect_success 'master: one of pack-2/pack-3 is redundant' '
# ALL | x x x x x x x x x x x x x x x x x x x # ALL | x x x x x x x x x x x x x x x x x x x
# #
############################################################################# #############################################################################
test_expect_success 'master: pack 2, 4, and 6 are redundant' ' test_expect_success 'main: pack 2, 4, and 6 are redundant' '
create_pack_in "$master_repo" P6 <<-EOF && create_pack_in "$main_repo" P6 <<-EOF &&
$N $N
$O $O
$Q $Q
EOF EOF
create_pack_in "$master_repo" P7 <<-EOF && create_pack_in "$main_repo" P7 <<-EOF &&
$P $P
$Q $Q
EOF EOF
( (
cd "$master_repo" && cd "$main_repo" &&
cat >expect <<-EOF && cat >expect <<-EOF &&
P2:$P2 P2:$P2
P4:$P4 P4:$P4
@ -254,12 +254,12 @@ test_expect_success 'master: pack 2, 4, and 6 are redundant' '
# ALL | x x x x x x x x x x x x x x x x x x x # ALL | x x x x x x x x x x x x x x x x x x x
# #
############################################################################# #############################################################################
test_expect_success 'master: pack-8 (subset of pack-1) is also redundant' ' test_expect_success 'main: pack-8 (subset of pack-1) is also redundant' '
create_pack_in "$master_repo" P8 <<-EOF && create_pack_in "$main_repo" P8 <<-EOF &&
$A $A
EOF EOF
( (
cd "$master_repo" && cd "$main_repo" &&
cat >expect <<-EOF && cat >expect <<-EOF &&
P2:$P2 P2:$P2
P4:$P4 P4:$P4
@ -272,18 +272,18 @@ test_expect_success 'master: pack-8 (subset of pack-1) is also redundant' '
) )
' '


test_expect_success 'master: clean loose objects' ' test_expect_success 'main: clean loose objects' '
( (
cd "$master_repo" && cd "$main_repo" &&
git prune-packed && git prune-packed &&
find objects -type f | sed -e "/objects\/pack\//d" >out && find objects -type f | sed -e "/objects\/pack\//d" >out &&
test_must_be_empty out test_must_be_empty out
) )
' '


test_expect_success 'master: remove redundant packs and pass fsck' ' test_expect_success 'main: remove redundant packs and pass fsck' '
( (
cd "$master_repo" && cd "$main_repo" &&
git pack-redundant --all | xargs rm && git pack-redundant --all | xargs rm &&
git fsck && git fsck &&
git pack-redundant --all >out && git pack-redundant --all >out &&
@ -292,12 +292,12 @@ test_expect_success 'master: remove redundant packs and pass fsck' '
' '


# The following test cases will execute inside `shared.git`, instead of # The following test cases will execute inside `shared.git`, instead of
# inside `master.git`. # inside `main.git`.
test_expect_success 'setup shared.git' ' test_expect_success 'setup shared.git' '
git clone --mirror "$master_repo" "$shared_repo" && git clone --mirror "$main_repo" "$shared_repo" &&
( (
cd "$shared_repo" && cd "$shared_repo" &&
printf "../../$master_repo/objects\n" >objects/info/alternates printf "../../$main_repo/objects\n" >objects/info/alternates
) )
' '


@ -312,7 +312,7 @@ test_expect_success 'shared: all packs are redundant, but no output without --al
############################################################################# #############################################################################
# Chart of packs and objects for this test case # Chart of packs and objects for this test case
# #
# ================= master.git ================ # ================= main.git ================
# | T A B C D E F G H I J K L M N O P Q R <----------+ # | T A B C D E F G H I J K L M N O P Q R <----------+
# ----+-------------------------------------- | # ----+-------------------------------------- |
# P1 | x x x x x x x x | # P1 | x x x x x x x x |
@ -394,7 +394,7 @@ test_expect_success 'shared: no redundant without --alt-odb' '
############################################################################# #############################################################################
# Chart of packs and objects for this test case # Chart of packs and objects for this test case
# #
# ================= master.git ================ # ================= main.git ================
# | T A B C D E F G H I J K L M N O P Q R <----------------+ # | T A B C D E F G H I J K L M N O P Q R <----------------+
# ----+-------------------------------------- | # ----+-------------------------------------- |
# P1 | x x x x x x x x | # P1 | x x x x x x x x |
@ -426,7 +426,7 @@ test_expect_success 'shared: one pack is redundant with --alt-odb' '
############################################################################# #############################################################################
# Chart of packs and objects for this test case # Chart of packs and objects for this test case
# #
# ================= master.git ================ # ================= main.git ================
# | T A B C D E F G H I J K L M N O P Q R <----------------+ # | T A B C D E F G H I J K L M N O P Q R <----------------+
# ----+-------------------------------------- | # ----+-------------------------------------- |
# P1 | x x x x x x x x | # P1 | x x x x x x x x |

View File

@ -6,7 +6,7 @@
test_description='See why rewinding head breaks send-pack test_description='See why rewinding head breaks send-pack


' '
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -69,20 +69,20 @@ test_expect_success 'pack the destination repository' '
' '


test_expect_success 'refuse pushing rewound head without --force' ' test_expect_success 'refuse pushing rewound head without --force' '
pushed_head=$(git rev-parse --verify master) && pushed_head=$(git rev-parse --verify main) &&
victim_orig=$(cd victim && git rev-parse --verify master) && victim_orig=$(cd victim && git rev-parse --verify main) &&
test_must_fail git send-pack ./victim master && test_must_fail git send-pack ./victim main &&
victim_head=$(cd victim && git rev-parse --verify master) && victim_head=$(cd victim && git rev-parse --verify main) &&
test "$victim_head" = "$victim_orig" && test "$victim_head" = "$victim_orig" &&
# this should update # this should update
git send-pack --force ./victim master && git send-pack --force ./victim main &&
victim_head=$(cd victim && git rev-parse --verify master) && victim_head=$(cd victim && git rev-parse --verify main) &&
test "$victim_head" = "$pushed_head" test "$victim_head" = "$pushed_head"
' '


test_expect_success 'push can be used to delete a ref' ' test_expect_success 'push can be used to delete a ref' '
( cd victim && git branch extra master ) && ( cd victim && git branch extra main ) &&
git send-pack ./victim :extra master && git send-pack ./victim :extra main &&
( cd victim && ( cd victim &&
test_must_fail git rev-parse --verify extra ) test_must_fail git rev-parse --verify extra )
' '
@ -92,9 +92,9 @@ test_expect_success 'refuse deleting push with denyDeletes' '
cd victim && cd victim &&
test_might_fail git branch -D extra && test_might_fail git branch -D extra &&
git config receive.denyDeletes true && git config receive.denyDeletes true &&
git branch extra master git branch extra main
) && ) &&
test_must_fail git send-pack ./victim :extra master test_must_fail git send-pack ./victim :extra main
' '


test_expect_success 'cannot override denyDeletes with git -c send-pack' ' test_expect_success 'cannot override denyDeletes with git -c send-pack' '
@ -102,10 +102,10 @@ test_expect_success 'cannot override denyDeletes with git -c send-pack' '
cd victim && cd victim &&
test_might_fail git branch -D extra && test_might_fail git branch -D extra &&
git config receive.denyDeletes true && git config receive.denyDeletes true &&
git branch extra master git branch extra main
) && ) &&
test_must_fail git -c receive.denyDeletes=false \ test_must_fail git -c receive.denyDeletes=false \
send-pack ./victim :extra master send-pack ./victim :extra main
' '


test_expect_success 'override denyDeletes with git -c receive-pack' ' test_expect_success 'override denyDeletes with git -c receive-pack' '
@ -113,11 +113,11 @@ test_expect_success 'override denyDeletes with git -c receive-pack' '
cd victim && cd victim &&
test_might_fail git branch -D extra && test_might_fail git branch -D extra &&
git config receive.denyDeletes true && git config receive.denyDeletes true &&
git branch extra master git branch extra main
) && ) &&
git send-pack \ git send-pack \
--receive-pack="git -c receive.denyDeletes=false receive-pack" \ --receive-pack="git -c receive.denyDeletes=false receive-pack" \
./victim :extra master ./victim :extra main
' '


test_expect_success 'denyNonFastforwards trumps --force' ' test_expect_success 'denyNonFastforwards trumps --force' '
@ -126,9 +126,9 @@ test_expect_success 'denyNonFastforwards trumps --force' '
test_might_fail git branch -D extra && test_might_fail git branch -D extra &&
git config receive.denyNonFastforwards true git config receive.denyNonFastforwards true
) && ) &&
victim_orig=$(cd victim && git rev-parse --verify master) && victim_orig=$(cd victim && git rev-parse --verify main) &&
test_must_fail git send-pack --force ./victim master^:master && test_must_fail git send-pack --force ./victim main^:main &&
victim_head=$(cd victim && git rev-parse --verify master) && victim_head=$(cd victim && git rev-parse --verify main) &&
test "$victim_orig" = "$victim_head" test "$victim_orig" = "$victim_head"
' '


@ -213,41 +213,41 @@ rewound_push_setup() {


test_expect_success 'pushing explicit refspecs respects forcing' ' test_expect_success 'pushing explicit refspecs respects forcing' '
rewound_push_setup && rewound_push_setup &&
parent_orig=$(cd parent && git rev-parse --verify master) && parent_orig=$(cd parent && git rev-parse --verify main) &&
( (
cd child && cd child &&
test_must_fail git send-pack ../parent \ test_must_fail git send-pack ../parent \
refs/heads/master:refs/heads/master refs/heads/main:refs/heads/main
) && ) &&
parent_head=$(cd parent && git rev-parse --verify master) && parent_head=$(cd parent && git rev-parse --verify main) &&
test "$parent_orig" = "$parent_head" && test "$parent_orig" = "$parent_head" &&
( (
cd child && cd child &&
git send-pack ../parent \ git send-pack ../parent \
+refs/heads/master:refs/heads/master +refs/heads/main:refs/heads/main
) && ) &&
parent_head=$(cd parent && git rev-parse --verify master) && parent_head=$(cd parent && git rev-parse --verify main) &&
child_head=$(cd child && git rev-parse --verify master) && child_head=$(cd child && git rev-parse --verify main) &&
test "$parent_head" = "$child_head" test "$parent_head" = "$child_head"
' '


test_expect_success 'pushing wildcard refspecs respects forcing' ' test_expect_success 'pushing wildcard refspecs respects forcing' '
rewound_push_setup && rewound_push_setup &&
parent_orig=$(cd parent && git rev-parse --verify master) && parent_orig=$(cd parent && git rev-parse --verify main) &&
( (
cd child && cd child &&
test_must_fail git send-pack ../parent \ test_must_fail git send-pack ../parent \
"refs/heads/*:refs/heads/*" "refs/heads/*:refs/heads/*"
) && ) &&
parent_head=$(cd parent && git rev-parse --verify master) && parent_head=$(cd parent && git rev-parse --verify main) &&
test "$parent_orig" = "$parent_head" && test "$parent_orig" = "$parent_head" &&
( (
cd child && cd child &&
git send-pack ../parent \ git send-pack ../parent \
"+refs/heads/*:refs/heads/*" "+refs/heads/*:refs/heads/*"
) && ) &&
parent_head=$(cd parent && git rev-parse --verify master) && parent_head=$(cd parent && git rev-parse --verify main) &&
child_head=$(cd child && git rev-parse --verify master) && child_head=$(cd child && git rev-parse --verify main) &&
test "$parent_head" = "$child_head" test "$parent_head" = "$child_head"
' '


@ -255,7 +255,7 @@ test_expect_success 'deny pushing to delete current branch' '
rewound_push_setup && rewound_push_setup &&
( (
cd child && cd child &&
test_must_fail git send-pack ../parent :refs/heads/master 2>errs test_must_fail git send-pack ../parent :refs/heads/main 2>errs
) )
' '


@ -286,9 +286,9 @@ test_expect_success 'receive-pack de-dupes .have lines' '
local=$(git -C fork rev-parse HEAD) && local=$(git -C fork rev-parse HEAD) &&
shared=$(git -C shared rev-parse only-shared) && shared=$(git -C shared rev-parse only-shared) &&
cat >expect <<-EOF && cat >expect <<-EOF &&
$local refs/heads/master $local refs/heads/main
$local refs/remotes/origin/HEAD $local refs/remotes/origin/HEAD
$local refs/remotes/origin/master $local refs/remotes/origin/main
$shared .have $shared .have
EOF EOF



View File

@ -15,11 +15,11 @@ test_expect_success setup '
git update-index a && git update-index a &&
tree1=$(git write-tree) && tree1=$(git write-tree) &&
commit1=$(echo modify | git commit-tree $tree1 -p $commit0) && commit1=$(echo modify | git commit-tree $tree1 -p $commit0) &&
git update-ref refs/heads/master $commit0 && git update-ref refs/heads/main $commit0 &&
git update-ref refs/heads/tofail $commit1 && git update-ref refs/heads/tofail $commit1 &&
git clone --bare ./. victim.git && git clone --bare ./. victim.git &&
GIT_DIR=victim.git git update-ref refs/heads/tofail $commit1 && GIT_DIR=victim.git git update-ref refs/heads/tofail $commit1 &&
git update-ref refs/heads/master $commit1 && git update-ref refs/heads/main $commit1 &&
git update-ref refs/heads/tofail $commit0 git update-ref refs/heads/tofail $commit0
' '


@ -38,7 +38,7 @@ echo "$@" >>$GIT_DIR/update.args
read x; printf %s "$x" >$GIT_DIR/update.stdin read x; printf %s "$x" >$GIT_DIR/update.stdin
echo STDOUT update $1 echo STDOUT update $1
echo STDERR update $1 >&2 echo STDERR update $1 >&2
test "$1" = refs/heads/master || exit test "$1" = refs/heads/main || exit
EOF EOF
chmod u+x victim.git/hooks/update chmod u+x victim.git/hooks/update


@ -62,11 +62,11 @@ chmod u+x victim.git/hooks/post-update


test_expect_success push ' test_expect_success push '
test_must_fail git send-pack --force ./victim.git \ test_must_fail git send-pack --force ./victim.git \
master tofail >send.out 2>send.err main tofail >send.out 2>send.err
' '


test_expect_success 'updated as expected' ' test_expect_success 'updated as expected' '
test $(GIT_DIR=victim.git git rev-parse master) = $commit1 && test $(GIT_DIR=victim.git git rev-parse main) = $commit1 &&
test $(GIT_DIR=victim.git git rev-parse tofail) = $commit1 test $(GIT_DIR=victim.git git rev-parse tofail) = $commit1
' '


@ -82,24 +82,24 @@ test_expect_success 'hooks ran' '
' '


test_expect_success 'pre-receive hook input' ' test_expect_success 'pre-receive hook input' '
(echo $commit0 $commit1 refs/heads/master && (echo $commit0 $commit1 refs/heads/main &&
echo $commit1 $commit0 refs/heads/tofail echo $commit1 $commit0 refs/heads/tofail
) | test_cmp - victim.git/pre-receive.stdin ) | test_cmp - victim.git/pre-receive.stdin
' '


test_expect_success 'update hook arguments' ' test_expect_success 'update hook arguments' '
(echo refs/heads/master $commit0 $commit1 && (echo refs/heads/main $commit0 $commit1 &&
echo refs/heads/tofail $commit1 $commit0 echo refs/heads/tofail $commit1 $commit0
) | test_cmp - victim.git/update.args ) | test_cmp - victim.git/update.args
' '


test_expect_success 'post-receive hook input' ' test_expect_success 'post-receive hook input' '
echo $commit0 $commit1 refs/heads/master | echo $commit0 $commit1 refs/heads/main |
test_cmp - victim.git/post-receive.stdin test_cmp - victim.git/post-receive.stdin
' '


test_expect_success 'post-update hook arguments' ' test_expect_success 'post-update hook arguments' '
echo refs/heads/master | echo refs/heads/main |
test_cmp - victim.git/post-update.args test_cmp - victim.git/post-update.args
' '


@ -120,8 +120,8 @@ test_expect_success 'send-pack produced no output' '
cat <<EOF >expect cat <<EOF >expect
remote: STDOUT pre-receive remote: STDOUT pre-receive
remote: STDERR pre-receive remote: STDERR pre-receive
remote: STDOUT update refs/heads/master remote: STDOUT update refs/heads/main
remote: STDERR update refs/heads/master remote: STDERR update refs/heads/main
remote: STDOUT update refs/heads/tofail remote: STDOUT update refs/heads/tofail
remote: STDERR update refs/heads/tofail remote: STDERR update refs/heads/tofail
remote: error: hook declined to update refs/heads/tofail remote: error: hook declined to update refs/heads/tofail
@ -143,7 +143,7 @@ test_expect_success 'pre-receive hook that forgets to read its input' '


for v in $(test_seq 100 999) for v in $(test_seq 100 999)
do do
git branch branch_$v master || return git branch branch_$v main || return
done && done &&
git push ./victim.git "+refs/heads/*:refs/heads/*" git push ./victim.git "+refs/heads/*:refs/heads/*"
' '

View File

@ -4,7 +4,7 @@
# #


test_description='Test the post-merge hook.' test_description='Test the post-merge hook.'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -18,7 +18,7 @@ test_expect_success setup '
git update-index a && git update-index a &&
tree1=$(git write-tree) && tree1=$(git write-tree) &&
commit1=$(echo modify | git commit-tree $tree1 -p $commit0) && commit1=$(echo modify | git commit-tree $tree1 -p $commit0) &&
git update-ref refs/heads/master $commit0 && git update-ref refs/heads/main $commit0 &&
git clone ./. clone1 && git clone ./. clone1 &&
GIT_DIR=clone1/.git git update-index --add a && GIT_DIR=clone1/.git git update-index --add a &&
git clone ./. clone2 && git clone ./. clone2 &&

View File

@ -4,7 +4,7 @@
# #


test_description='Test the post-checkout hook.' test_description='Test the post-checkout hook.'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -23,7 +23,7 @@ test_expect_success setup '


test_expect_success 'post-checkout receives the right arguments with HEAD unchanged ' ' test_expect_success 'post-checkout receives the right arguments with HEAD unchanged ' '
test_when_finished "rm -f .git/post-checkout.args" && test_when_finished "rm -f .git/post-checkout.args" &&
git checkout master && git checkout main &&
read old new flag <.git/post-checkout.args && read old new flag <.git/post-checkout.args &&
test $old = $new && test $flag = 1 test $old = $new && test $flag = 1
' '
@ -44,14 +44,14 @@ test_expect_success 'post-checkout receives the right args with HEAD changed ' '


test_expect_success 'post-checkout receives the right args when not switching branches ' ' test_expect_success 'post-checkout receives the right args when not switching branches ' '
test_when_finished "rm -f .git/post-checkout.args" && test_when_finished "rm -f .git/post-checkout.args" &&
git checkout master -- three.t && git checkout main -- three.t &&
read old new flag <.git/post-checkout.args && read old new flag <.git/post-checkout.args &&
test $old = $new && test $flag = 0 test $old = $new && test $flag = 0
' '


test_expect_success 'post-checkout is triggered on rebase' ' test_expect_success 'post-checkout is triggered on rebase' '
test_when_finished "rm -f .git/post-checkout.args" && test_when_finished "rm -f .git/post-checkout.args" &&
git checkout -b rebase-test master && git checkout -b rebase-test main &&
rm -f .git/post-checkout.args && rm -f .git/post-checkout.args &&
git rebase rebase-on-me && git rebase rebase-on-me &&
read old new flag <.git/post-checkout.args && read old new flag <.git/post-checkout.args &&

View File

@ -2,7 +2,7 @@


test_description='tracking branch update checks for git push' test_description='tracking branch update checks for git push'


GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -33,9 +33,9 @@ test_expect_success 'prepare pushable branches' '
git checkout -b b2 origin/b2 && git checkout -b b2 origin/b2 &&
echo aa-b2 >>file && echo aa-b2 >>file &&
git commit -a -m aa-b2 && git commit -a -m aa-b2 &&
git checkout master && git checkout main &&
echo aa-master >>file && echo aa-main >>file &&
git commit -a -m aa-master git commit -a -m aa-main
' '


test_expect_success 'mixed-success push returns error' ' test_expect_success 'mixed-success push returns error' '
@ -43,7 +43,7 @@ test_expect_success 'mixed-success push returns error' '
' '


test_expect_success 'check tracking branches updated correctly after push' ' test_expect_success 'check tracking branches updated correctly after push' '
test "$(git rev-parse origin/master)" = "$(git rev-parse master)" test "$(git rev-parse origin/main)" = "$(git rev-parse main)"
' '


test_expect_success 'check tracking branches not updated for failed refs' ' test_expect_success 'check tracking branches not updated for failed refs' '

View File

@ -2,7 +2,7 @@


test_description='forced push to replace commit we do not have' test_description='forced push to replace commit we do not have'


GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -16,7 +16,7 @@ test_expect_success setup '
mkdir another && ( mkdir another && (
cd another && cd another &&
git init && git init &&
git fetch --update-head-ok .. master:master git fetch --update-head-ok .. main:main
) && ) &&


>file2 && git add file2 && test_tick && >file2 && git add file2 && test_tick &&
@ -28,7 +28,7 @@ test_expect_success 'non forced push should die not segfault' '


( (
cd another && cd another &&
test_must_fail git push .. master:master test_must_fail git push .. main:main
) )


' '
@ -37,7 +37,7 @@ test_expect_success 'forced push should succeed' '


( (
cd another && cd another &&
git push .. +master:master git push .. +main:main
) )


' '

View File

@ -4,7 +4,7 @@
# #


test_description='Test the post-rewrite hook.' test_description='Test the post-rewrite hook.'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -17,7 +17,7 @@ test_expect_success 'setup' '
git checkout A^0 && git checkout A^0 &&
test_commit E bar E && test_commit E bar E &&
test_commit F foo F && test_commit F foo F &&
git checkout master git checkout main
' '


mkdir .git/hooks mkdir .git/hooks

View File

@ -2,7 +2,7 @@


test_description='git receive-pack with alternate ref filtering' test_description='git receive-pack with alternate ref filtering'


GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME


. ./test-lib.sh . ./test-lib.sh
@ -10,9 +10,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
test_expect_success 'setup' ' test_expect_success 'setup' '
test_commit base && test_commit base &&
git clone -s --bare . fork && git clone -s --bare . fork &&
git checkout -b public/branch master && git checkout -b public/branch main &&
test_commit public && test_commit public &&
git checkout -b private/branch master && git checkout -b private/branch main &&
test_commit private test_commit private
' '