summaryrefslogtreecommitdiff
path: root/t/t5703-upload-pack-ref-in-want.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t5703-upload-pack-ref-in-want.sh')
-rwxr-xr-xt/t5703-upload-pack-ref-in-want.sh73
1 files changed, 39 insertions, 34 deletions
diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh
index d9ecf0f4a9..e9e471621d 100755
--- a/t/t5703-upload-pack-ref-in-want.sh
+++ b/t/t5703-upload-pack-ref-in-want.sh
@@ -2,6 +2,9 @@
test_description='upload-pack ref-in-want'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
. ./test-lib.sh
get_actual_refs () {
@@ -16,7 +19,8 @@ get_actual_commits () {
test-tool pkt-line unpack-sideband <out >o.pack &&
git index-pack o.pack &&
git verify-pack -v o.idx >objs &&
- grep commit objs | cut -d" " -f1 | sort >actual_commits
+ sed -n -e 's/\([0-9a-f][0-9a-f]*\) commit .*/\1/p' objs >objs.sed &&
+ sort >actual_commits <objs.sed
}
check_output () {
@@ -38,12 +42,13 @@ write_command () {
# c(o/foo) d(o/bar)
# \ /
-# b e(baz) f(master)
+# b e(baz) f(main)
# \__ | __/
# \ | /
# a
test_expect_success 'setup repository' '
test_commit a &&
+ git branch -M main &&
git checkout -b o/foo &&
test_commit b &&
test_commit c &&
@@ -51,7 +56,7 @@ test_expect_success 'setup repository' '
test_commit d &&
git checkout -b baz a &&
test_commit e &&
- git checkout master &&
+ git checkout main &&
test_commit f
'
@@ -88,7 +93,7 @@ test_expect_success 'invalid want-ref line' '
test_expect_success 'basic want-ref' '
oid=$(git rev-parse f) &&
cat >expected_refs <<-EOF &&
- $oid refs/heads/master
+ $oid refs/heads/main
EOF
git rev-parse f >expected_commits &&
@@ -97,7 +102,7 @@ test_expect_success 'basic want-ref' '
$(write_command fetch)
0001
no-progress
- want-ref refs/heads/master
+ want-ref refs/heads/main
have $oid
done
0000
@@ -135,7 +140,7 @@ test_expect_success 'multiple want-ref lines' '
test_expect_success 'mix want and want-ref' '
oid=$(git rev-parse f) &&
cat >expected_refs <<-EOF &&
- $oid refs/heads/master
+ $oid refs/heads/main
EOF
git rev-parse e f >expected_commits &&
@@ -143,7 +148,7 @@ test_expect_success 'mix want and want-ref' '
$(write_command fetch)
0001
no-progress
- want-ref refs/heads/master
+ want-ref refs/heads/main
want $(git rev-parse e)
have $(git rev-parse a)
done
@@ -182,7 +187,7 @@ LOCAL_PRISTINE="$(pwd)/local_pristine"
# $REPO
# c(o/foo) d(o/bar)
# \ /
-# b e(baz) f(master)
+# b e(baz) f(main)
# \__ | __/
# \ | /
# a
@@ -193,10 +198,10 @@ LOCAL_PRISTINE="$(pwd)/local_pristine"
# .
# .
# |
-# a(master)
+# a(main)
test_expect_success 'setup repos for fetching with ref-in-want tests' '
(
- git init "$REPO" &&
+ git init -b main "$REPO" &&
cd "$REPO" &&
test_commit a &&
@@ -209,7 +214,7 @@ test_expect_success 'setup repos for fetching with ref-in-want tests' '
test_commit_bulk --id=s 33 &&
# Add novel commits to upstream
- git checkout master &&
+ git checkout main &&
cd "$REPO" &&
git checkout -b o/foo &&
test_commit b &&
@@ -218,7 +223,7 @@ test_expect_success 'setup repos for fetching with ref-in-want tests' '
test_commit d &&
git checkout -b baz a &&
test_commit e &&
- git checkout master &&
+ git checkout main &&
test_commit f
) &&
git -C "$REPO" config uploadpack.allowRefInWant true &&
@@ -245,12 +250,12 @@ test_expect_success 'fetching multiple refs' '
rm -rf local &&
cp -r "$LOCAL_PRISTINE" local &&
- GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin master baz &&
+ GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin main baz &&
- git -C "$REPO" rev-parse "master" "baz" >expected &&
- git -C local rev-parse refs/remotes/origin/master refs/remotes/origin/baz >actual &&
+ git -C "$REPO" rev-parse "main" "baz" >expected &&
+ git -C local rev-parse refs/remotes/origin/main refs/remotes/origin/baz >actual &&
test_cmp expected actual &&
- grep "want-ref refs/heads/master" log &&
+ grep "want-ref refs/heads/main" log &&
grep "want-ref refs/heads/baz" log
'
@@ -261,13 +266,13 @@ test_expect_success 'fetching ref and exact OID' '
cp -r "$LOCAL_PRISTINE" local &&
oid=$(git -C "$REPO" rev-parse b) &&
GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin \
- master "$oid":refs/heads/actual &&
+ main "$oid":refs/heads/actual &&
- git -C "$REPO" rev-parse "master" "b" >expected &&
- git -C local rev-parse refs/remotes/origin/master refs/heads/actual >actual &&
+ git -C "$REPO" rev-parse "main" "b" >expected &&
+ git -C local rev-parse refs/remotes/origin/main refs/heads/actual >actual &&
test_cmp expected actual &&
grep "want $oid" log &&
- grep "want-ref refs/heads/master" log
+ grep "want-ref refs/heads/main" log
'
test_expect_success 'fetching with wildcard that does not match any refs' '
@@ -301,7 +306,7 @@ LOCAL_PRISTINE="$(pwd)/local_pristine"
test_expect_success 'setup repos for change-while-negotiating test' '
(
- git init "$REPO" &&
+ git init -b main "$REPO" &&
cd "$REPO" &&
>.git/git-daemon-export-ok &&
test_commit m1 &&
@@ -316,7 +321,7 @@ test_expect_success 'setup repos for change-while-negotiating test' '
test_commit_bulk --id=s 33 &&
# Add novel commits to upstream
- git checkout master &&
+ git checkout main &&
cd "$REPO" &&
test_commit m2 &&
test_commit m3 &&
@@ -342,7 +347,7 @@ test_expect_success 'server is initially ahead - no ref in want' '
git -C "$REPO" config uploadpack.allowRefInWant false &&
rm -rf local &&
cp -r "$LOCAL_PRISTINE" local &&
- inconsistency master $(test_oid numeric) &&
+ inconsistency main $(test_oid numeric) &&
test_must_fail git -C local fetch 2>err &&
test_i18ngrep "fatal: remote error: upload-pack: not our ref" err
'
@@ -351,11 +356,11 @@ test_expect_success 'server is initially ahead - ref in want' '
git -C "$REPO" config uploadpack.allowRefInWant true &&
rm -rf local &&
cp -r "$LOCAL_PRISTINE" local &&
- inconsistency master $(test_oid numeric) &&
+ inconsistency main $(test_oid numeric) &&
git -C local fetch &&
- git -C "$REPO" rev-parse --verify master >expected &&
- git -C local rev-parse --verify refs/remotes/origin/master >actual &&
+ git -C "$REPO" rev-parse --verify main >expected &&
+ git -C local rev-parse --verify refs/remotes/origin/main >actual &&
test_cmp expected actual
'
@@ -363,11 +368,11 @@ test_expect_success 'server is initially behind - no ref in want' '
git -C "$REPO" config uploadpack.allowRefInWant false &&
rm -rf local &&
cp -r "$LOCAL_PRISTINE" local &&
- inconsistency master "master^" &&
+ inconsistency main "main^" &&
git -C local fetch &&
- git -C "$REPO" rev-parse --verify "master^" >expected &&
- git -C local rev-parse --verify refs/remotes/origin/master >actual &&
+ git -C "$REPO" rev-parse --verify "main^" >expected &&
+ git -C local rev-parse --verify refs/remotes/origin/main >actual &&
test_cmp expected actual
'
@@ -375,11 +380,11 @@ test_expect_success 'server is initially behind - ref in want' '
git -C "$REPO" config uploadpack.allowRefInWant true &&
rm -rf local &&
cp -r "$LOCAL_PRISTINE" local &&
- inconsistency master "master^" &&
+ inconsistency main "main^" &&
git -C local fetch &&
- git -C "$REPO" rev-parse --verify "master" >expected &&
- git -C local rev-parse --verify refs/remotes/origin/master >actual &&
+ git -C "$REPO" rev-parse --verify "main" >expected &&
+ git -C local rev-parse --verify refs/remotes/origin/main >actual &&
test_cmp expected actual
'
@@ -387,10 +392,10 @@ test_expect_success 'server loses a ref - ref in want' '
git -C "$REPO" config uploadpack.allowRefInWant true &&
rm -rf local &&
cp -r "$LOCAL_PRISTINE" local &&
- echo "s/master/raster/" >"$HTTPD_ROOT_PATH/one-time-perl" &&
+ echo "s/main/rain/" >"$HTTPD_ROOT_PATH/one-time-perl" &&
test_must_fail git -C local fetch 2>err &&
- test_i18ngrep "fatal: remote error: unknown ref refs/heads/raster" err
+ test_i18ngrep "fatal: remote error: unknown ref refs/heads/rain" err
'
# DO NOT add non-httpd-specific tests here, because the last part of this