blame.h: drop extern on func declaration
[gitweb.git] / t / t5510-fetch.sh
index 6f1450eb698fa5563528f2437375681577647690..62308be499ffd862484eb23de61850d00f80720c 100755 (executable)
@@ -867,4 +867,82 @@ test_expect_success C_LOCALE_OUTPUT 'fetch compact output' '
        test_cmp expect actual
 '
 
+setup_negotiation_tip () {
+       SERVER="$1"
+       URL="$2"
+       USE_PROTOCOL_V2="$3"
+
+       rm -rf "$SERVER" client trace &&
+       git init "$SERVER" &&
+       test_commit -C "$SERVER" alpha_1 &&
+       test_commit -C "$SERVER" alpha_2 &&
+       git -C "$SERVER" checkout --orphan beta &&
+       test_commit -C "$SERVER" beta_1 &&
+       test_commit -C "$SERVER" beta_2 &&
+
+       git clone "$URL" client &&
+
+       if test "$USE_PROTOCOL_V2" -eq 1
+       then
+               git -C "$SERVER" config protocol.version 2 &&
+               git -C client config protocol.version 2
+       fi &&
+
+       test_commit -C "$SERVER" beta_s &&
+       git -C "$SERVER" checkout master &&
+       test_commit -C "$SERVER" alpha_s &&
+       git -C "$SERVER" tag -d alpha_1 alpha_2 beta_1 beta_2
+}
+
+check_negotiation_tip () {
+       # Ensure that {alpha,beta}_1 are sent as "have", but not {alpha_beta}_2
+       ALPHA_1=$(git -C client rev-parse alpha_1) &&
+       grep "fetch> have $ALPHA_1" trace &&
+       BETA_1=$(git -C client rev-parse beta_1) &&
+       grep "fetch> have $BETA_1" trace &&
+       ALPHA_2=$(git -C client rev-parse alpha_2) &&
+       ! grep "fetch> have $ALPHA_2" trace &&
+       BETA_2=$(git -C client rev-parse beta_2) &&
+       ! grep "fetch> have $BETA_2" trace
+}
+
+test_expect_success '--negotiation-tip limits "have" lines sent' '
+       setup_negotiation_tip server server 0 &&
+       GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch \
+               --negotiation-tip=alpha_1 --negotiation-tip=beta_1 \
+               origin alpha_s beta_s &&
+       check_negotiation_tip
+'
+
+test_expect_success '--negotiation-tip understands globs' '
+       setup_negotiation_tip server server 0 &&
+       GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch \
+               --negotiation-tip=*_1 \
+               origin alpha_s beta_s &&
+       check_negotiation_tip
+'
+
+test_expect_success '--negotiation-tip understands abbreviated SHA-1' '
+       setup_negotiation_tip server server 0 &&
+       GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch \
+               --negotiation-tip=$(git -C client rev-parse --short alpha_1) \
+               --negotiation-tip=$(git -C client rev-parse --short beta_1) \
+               origin alpha_s beta_s &&
+       check_negotiation_tip
+'
+
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+test_expect_success '--negotiation-tip limits "have" lines sent with HTTP protocol v2' '
+       setup_negotiation_tip "$HTTPD_DOCUMENT_ROOT_PATH/server" \
+               "$HTTPD_URL/smart/server" 1 &&
+       GIT_TRACE_PACKET="$(pwd)/trace" git -C client fetch \
+               --negotiation-tip=alpha_1 --negotiation-tip=beta_1 \
+               origin alpha_s beta_s &&
+       check_negotiation_tip
+'
+
+stop_httpd
+
 test_done