summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/t5510-fetch.sh13
-rwxr-xr-xt/t5516-fetch-push.sh4
-rwxr-xr-xt/t5549-fetch-push-http.sh72
3 files changed, 88 insertions, 1 deletions
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index e83b2a6506..a0faf0dd94 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -1214,6 +1214,19 @@ test_expect_success '--negotiation-tip understands abbreviated SHA-1' '
check_negotiation_tip
'
+test_expect_success '--negotiation-tip rejects missing OIDs' '
+ setup_negotiation_tip server server 0 &&
+ test_must_fail git -C client fetch \
+ --negotiation-tip=alpha_1 \
+ --negotiation-tip=$(test_oid zero) \
+ origin alpha_s beta_s 2>err &&
+ cat >fatal-expect <<-EOF &&
+ fatal: the object $(test_oid zero) does not exist
+EOF
+ grep fatal: err >fatal-actual &&
+ test_cmp fatal-expect fatal-actual
+'
+
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 0916f76302..4db8edd9c8 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -201,6 +201,7 @@ test_expect_success 'push with negotiation' '
# Without negotiation
mk_empty testrepo &&
git push testrepo $the_first_commit:refs/remotes/origin/first_commit &&
+ test_commit -C testrepo unrelated_commit &&
git -C testrepo config receive.hideRefs refs/remotes/origin/first_commit &&
echo now pushing without negotiation &&
GIT_TRACE2_EVENT="$(pwd)/event" git -c protocol.version=2 push testrepo refs/heads/main:refs/remotes/origin/main &&
@@ -210,6 +211,7 @@ test_expect_success 'push with negotiation' '
rm event &&
mk_empty testrepo &&
git push testrepo $the_first_commit:refs/remotes/origin/first_commit &&
+ test_commit -C testrepo unrelated_commit &&
git -C testrepo config receive.hideRefs refs/remotes/origin/first_commit &&
GIT_TRACE2_EVENT="$(pwd)/event" git -c protocol.version=2 -c push.negotiate=1 push testrepo refs/heads/main:refs/remotes/origin/main &&
grep_wrote 2 event # 1 commit, 1 tree
@@ -219,6 +221,7 @@ test_expect_success 'push with negotiation proceeds anyway even if negotiation f
rm event &&
mk_empty testrepo &&
git push testrepo $the_first_commit:refs/remotes/origin/first_commit &&
+ test_commit -C testrepo unrelated_commit &&
git -C testrepo config receive.hideRefs refs/remotes/origin/first_commit &&
GIT_TEST_PROTOCOL_VERSION=0 GIT_TRACE2_EVENT="$(pwd)/event" \
git -c push.negotiate=1 push testrepo refs/heads/main:refs/remotes/origin/main 2>err &&
@@ -1767,5 +1770,4 @@ test_expect_success 'denyCurrentBranch and worktrees' '
git -C cloned push origin HEAD:new-wt &&
test_must_fail git -C cloned push --delete origin new-wt
'
-
test_done
diff --git a/t/t5549-fetch-push-http.sh b/t/t5549-fetch-push-http.sh
new file mode 100755
index 0000000000..2cdebcb735
--- /dev/null
+++ b/t/t5549-fetch-push-http.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+test_description='fetch/push functionality using the HTTP protocol'
+
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server"
+URI="$HTTPD_URL/smart/server"
+
+grep_wrote () {
+ object_count=$1
+ file_name=$2
+ grep 'write_pack_file/wrote.*"value":"'$1'"' $2
+}
+
+setup_client_and_server () {
+ git init client &&
+ test_when_finished 'rm -rf client' &&
+ test_commit -C client first_commit &&
+ test_commit -C client second_commit &&
+
+ git init "$SERVER" &&
+ test_when_finished 'rm -rf "$SERVER"' &&
+ test_config -C "$SERVER" http.receivepack true &&
+ test_commit -C "$SERVER" unrelated_commit &&
+ git -C client push "$URI" first_commit:refs/remotes/origin/first_commit &&
+ git -C "$SERVER" config receive.hideRefs refs/remotes/origin/first_commit
+}
+
+test_expect_success 'push without negotiation (for comparing object counts with the next test)' '
+ setup_client_and_server &&
+
+ GIT_TRACE2_EVENT="$(pwd)/event" git -C client -c protocol.version=2 \
+ push "$URI" refs/heads/main:refs/remotes/origin/main &&
+ test_when_finished "rm -f event" &&
+ grep_wrote 6 event # 2 commits, 2 trees, 2 blobs
+'
+
+test_expect_success 'push with negotiation' '
+ setup_client_and_server &&
+
+ GIT_TRACE2_EVENT="$(pwd)/event" git -C client -c protocol.version=2 -c push.negotiate=1 \
+ push "$URI" refs/heads/main:refs/remotes/origin/main &&
+ test_when_finished "rm -f event" &&
+ grep_wrote 3 event # 1 commit, 1 tree, 1 blob
+'
+
+test_expect_success 'push with negotiation proceeds anyway even if negotiation fails' '
+ setup_client_and_server &&
+
+ # Use protocol v0 to make negotiation fail (because protocol v0 does
+ # not support the "wait-for-done" capability, which is required for
+ # push negotiation)
+ GIT_TEST_PROTOCOL_VERSION=0 GIT_TRACE2_EVENT="$(pwd)/event" git -C client -c push.negotiate=1 \
+ push "$URI" refs/heads/main:refs/remotes/origin/main 2>err &&
+ test_when_finished "rm -f event" &&
+ grep_wrote 6 event && # 2 commits, 2 trees, 2 blobs
+
+ cat >warning-expect <<-EOF &&
+ warning: --negotiate-only requires protocol v2
+ warning: push negotiation failed; proceeding anyway with push
+EOF
+ grep warning: err >warning-actual &&
+ test_cmp warning-expect warning-actual
+'
+
+test_done