{"thread":{"id":"59325","subject":"[PATCH 01/20] t5541: run \"used receive-pack service\" test earlier","startedAt":"2023-02-28T23:39:17Z","lastAt":"2023-02-28T23:40:57Z","messageCount":10,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":20},"messages":[{"id":"472864","messageId":"20230228233913.684853-1-gitster@pobox.com","threadId":"59325","inReplyTo":null,"subject":"[PATCH 01/20] t5541: run \"used receive-pack service\" test earlier","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-02-28T23:38:54Z","receivedAt":"2023-02-28T23:39:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nThere's a test in t5541 that confirms that \"git push\" makes two requests\n(a GET to /info/refs, and a POST to /git-receive-pack). However, it's a\nnoop unless GIT_TEST_PROTOCOL_VERSION is set to \"0\", due to 8a1b0978ab\n(test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate,\n2019-12-23).\n\nThis means that almost nobody runs it. And indeed, it has been broken\nsince b0c4adcdd7 (remote-curl: send Accept-Language header to server,\n2022-07-11). But the fault is not in that commit, but in how brittle the\ntest is. It runs after several operations have been performed, which\nmeans that it expects to see the complete set of requests made so far in\nthe script. Commit b0c4adcdd7 added a new test, which means that the\n\"used receive-pack service\" test must be updated, too.\n\nLet's fix this by making the test less brittle. We'll move it higher in\nthe script, right after the first push has completed. And we'll clear\nthe access log right before doing the push, so we'll see only the\nrequests from that command.\n\nThis is technically testing less, in that we won't check that all of\nthose other requests also correctly used smart http. But there's no\nparticular reason think that if the first one did, the others wouldn't.\n\nAfter this patch, running:\n\n  GIT_TEST_PROTOCOL_VERSION=0 ./t5541-http-push-smart.sh\n\npasses, whereas it did not before.\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t5541-http-push-smart.sh | 44 ++++++++++++++++----------------------\n 1 file changed, 18 insertions(+), 26 deletions(-)\n\ndiff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh\nindex fbad2d5ff5..ef39d14ed2 100755\n--- a/t/t5541-http-push-smart.sh\n+++ b/t/t5541-http-push-smart.sh\n@@ -41,10 +41,6 @@ GET  /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200\n EOF\n test_expect_success 'no empty path components' '\n-\t# Clear the log, so that it does not affect the \"used receive-pack\n-\t# service\" test which reads the log too.\n-\ttest_when_finished \">\\\"\\$HTTPD_ROOT_PATH\\\"/access.log\" &&\n-\n \t# In the URL, add a trailing slash, and see if git appends yet another\n \t# slash.\n \tcd \"$ROOT_PATH\" &&\n@@ -67,6 +63,10 @@ test_expect_success 'clone remote repository' '\n '\n \n test_expect_success 'push to remote repository (standard)' '\n+\t# Clear the log, so that the \"used receive-pack service\" test below\n+\t# sees just what we did here.\n+\t>\"$HTTPD_ROOT_PATH\"/access.log &&\n+\n \tcd \"$ROOT_PATH\"/test_repo_clone &&\n \t: >path2 &&\n \tgit add path2 &&\n@@ -80,6 +80,20 @@ test_expect_success 'push to remote repository (standard)' '\n \t test $HEAD = $(git rev-parse --verify HEAD))\n '\n \n+test_expect_success 'used receive-pack service' '\n+\tcat >exp <<-\\EOF &&\n+\tGET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200\n+\tPOST /smart/test_repo.git/git-receive-pack HTTP/1.1 200\n+\tEOF\n+\n+\t# NEEDSWORK: If the overspecification of the expected result is reduced, we\n+\t# might be able to run this test in all protocol versions.\n+\tif test \"$GIT_TEST_PROTOCOL_VERSION\" = 0\n+\tthen\n+\t\tcheck_access_log exp\n+\tfi\n+'\n+\n test_expect_success 'push to remote repository (standard) with sending Accept-Language' '\n \tcat >exp <<-\\EOF &&\n \t=> Send header: Accept-Language: ko-KR, *;q=0.9\n@@ -141,28 +155,6 @@ test_expect_success 'rejected update prints status' '\n '\n rm -f \"$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update\"\n \n-cat >exp <<EOF\n-GET  /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n-POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200\n-GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200\n-POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200\n-GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200\n-GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200\n-POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200\n-GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200\n-POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200\n-GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200\n-POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200\n-EOF\n-test_expect_success 'used receive-pack service' '\n-\t# NEEDSWORK: If the overspecification of the expected result is reduced, we\n-\t# might be able to run this test in all protocol versions.\n-\tif test \"$GIT_TEST_PROTOCOL_VERSION\" = 0\n-\tthen\n-\t\tcheck_access_log exp\n-\tfi\n-'\n-\n test_http_push_nonff \"$HTTPD_DOCUMENT_ROOT_PATH\"/test_repo.git \\\n \t\"$ROOT_PATH\"/test_repo_clone main \t\tsuccess\n \n-- \n2.40.0-rc0-32-ga0f05f6840\n\n"},{"id":"472865","messageId":"20230228233913.684853-2-gitster@pobox.com","threadId":"59325","inReplyTo":"20230228233913.684853-1-gitster@pobox.com","subject":"[PATCH 02/20] t5541: stop marking \"used receive-pack service\" test as v0 only","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-02-28T23:38:55Z","receivedAt":"2023-02-28T23:39:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nWe have a test which checks to see if a request to git-receive-pack was\nmade. Originally, it was checking the entire set of requests made in the\nscript so far, including clones, and thus it would break when run with\nthe v2 protocol (since that implies an extra request for fetches).\n\nSince the previous commit, though, we are only checking the requests\nmade by a single push. And since there is no v2 push protocol, the test\nnow passes no matter what's in GIT_TEST_PROTOCOL_VERSION. We can just\nrun it all the time.\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t5541-http-push-smart.sh | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh\nindex ef39d14ed2..f8bf533c33 100755\n--- a/t/t5541-http-push-smart.sh\n+++ b/t/t5541-http-push-smart.sh\n@@ -86,12 +86,7 @@ test_expect_success 'used receive-pack service' '\n \tPOST /smart/test_repo.git/git-receive-pack HTTP/1.1 200\n \tEOF\n \n-\t# NEEDSWORK: If the overspecification of the expected result is reduced, we\n-\t# might be able to run this test in all protocol versions.\n-\tif test \"$GIT_TEST_PROTOCOL_VERSION\" = 0\n-\tthen\n-\t\tcheck_access_log exp\n-\tfi\n+\tcheck_access_log exp\n '\n \n test_expect_success 'push to remote repository (standard) with sending Accept-Language' '\n-- \n2.40.0-rc0-32-ga0f05f6840\n\n"},{"id":"472866","messageId":"20230228233913.684853-3-gitster@pobox.com","threadId":"59325","inReplyTo":"20230228233913.684853-1-gitster@pobox.com","subject":"[PATCH 03/20] t5541: simplify and move \"no empty path components\" test","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-02-28T23:38:56Z","receivedAt":"2023-02-28T23:39:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nCommit 9ee6bcd398 (t5541-http-push: add test for URLs with trailing\nslash, 2010-04-08) added a test that clones a URL with a trailing slash,\nand confirms that we don't send a doubled slash (like \"$url//info/refs\")\nto the server.\n\nBut this test makes no sense in t5541, which is about pushing. It should\nhave been added in t5551. Let's move it there.\n\nBut putting it at the end is tricky, since it checks the entire contents\nof the Apache access log. We could get around this by clearing the log\nbefore our test. But there's an even simpler solution: just make sure no\ndoubled slashes appear in the log (fortunately, \"http://\" does not\nappear in the log itself).\n\nAs a bonus, this also lets us drop the check for the v0 protocol (which\nis otherwise necessary since v2 makes multiple requests, and\ncheck_access_log insists on exactly matching the number of requests,\neven though we don't care about that here).\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t5541-http-push-smart.sh  | 18 ------------------\n t/t5551-http-fetch-smart.sh |  9 +++++++++\n 2 files changed, 9 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh\nindex f8bf533c33..d0211cd8be 100755\n--- a/t/t5541-http-push-smart.sh\n+++ b/t/t5541-http-push-smart.sh\n@@ -36,24 +36,6 @@ test_expect_success 'setup remote repository' '\n \n setup_askpass_helper\n \n-cat >exp <<EOF\n-GET  /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n-POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200\n-EOF\n-test_expect_success 'no empty path components' '\n-\t# In the URL, add a trailing slash, and see if git appends yet another\n-\t# slash.\n-\tcd \"$ROOT_PATH\" &&\n-\tgit clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone &&\n-\n-\t# NEEDSWORK: If the overspecification of the expected result is reduced, we\n-\t# might be able to run this test in all protocol versions.\n-\tif test \"$GIT_TEST_PROTOCOL_VERSION\" = 0\n-\tthen\n-\t\tcheck_access_log exp\n-\tfi\n-'\n-\n test_expect_success 'clone remote repository' '\n \trm -rf test_repo_clone &&\n \tgit clone $HTTPD_URL/smart/test_repo.git test_repo_clone &&\ndiff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh\nindex bc0719a4fc..10b7e7cda2 100755\n--- a/t/t5551-http-fetch-smart.sh\n+++ b/t/t5551-http-fetch-smart.sh\n@@ -666,4 +666,13 @@ test_expect_success 'push warns or fails when using username:password' '\n \ttest_line_count -ge 1 warnings\n '\n \n+test_expect_success 'no empty path components' '\n+\t# In the URL, add a trailing slash, and see if git appends yet another\n+\t# slash.\n+\tgit clone $HTTPD_URL/smart/repo.git/ clone-with-slash &&\n+\n+\tstrip_access_log >log &&\n+\t! grep \"//\" log\n+'\n+\n test_done\n-- \n2.40.0-rc0-32-ga0f05f6840\n\n"},{"id":"472867","messageId":"20230228233913.684853-4-gitster@pobox.com","threadId":"59325","inReplyTo":"20230228233913.684853-1-gitster@pobox.com","subject":"[PATCH 04/20] t5551: drop redundant grep for Accept-Language","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-02-28T23:38:57Z","receivedAt":"2023-02-28T23:39:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nCommit b0c4adcdd7 (remote-curl: send Accept-Language header to server,\n2022-07-11) added tests to make sure the header is sent via HTTP.\nHowever, it checks in two places:\n\n  1. In the expected trace output, we check verbatim for the header and\n     its value.\n\n  2. Afterwards, we grep for the header again in the trace file.\n\nThis (2) is probably cargo-culted from the earlier grep for\nAccept-Encoding. It is needed for the encoding because we smudge the\nvalue of that header when doing the verbatim check; see 1a53e692af\n(remote-curl: accept all encodings supported by curl, 2018-05-22).\n\nBut we don't do so for the language header, so any problem that the\n\"grep\" would catch in (2) would already have been caught by (1).\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t5551-http-fetch-smart.sh | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh\nindex 10b7e7cda2..29d489768e 100755\n--- a/t/t5551-http-fetch-smart.sh\n+++ b/t/t5551-http-fetch-smart.sh\n@@ -103,10 +103,7 @@ test_expect_success 'clone http repository' '\n \t\ttest_cmp exp actual.smudged &&\n \n \t\tgrep \"Accept-Encoding:.*gzip\" actual >actual.gzip &&\n-\t\ttest_line_count = 2 actual.gzip &&\n-\n-\t\tgrep \"Accept-Language: ko-KR, *\" actual >actual.language &&\n-\t\ttest_line_count = 2 actual.language\n+\t\ttest_line_count = 2 actual.gzip\n \tfi\n '\n \n-- \n2.40.0-rc0-32-ga0f05f6840\n\n"},{"id":"472869","messageId":"20230228233913.684853-5-gitster@pobox.com","threadId":"59325","inReplyTo":"20230228233913.684853-1-gitster@pobox.com","subject":"[PATCH 05/20] t5551: lower-case headers in expected curl trace","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-02-28T23:38:58Z","receivedAt":"2023-02-28T23:39:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nThere's a test in t5551 which checks the curl trace (after simplifying\nit a bit). It doesn't work with HTTP/2, because in that case curl\noutputs all of the headers in lower-case. Even though this test is run\nwith HTTP/2 by t5559, nobody has noticed because checking the trace only\nhappens if GIT_TEST_PROTOCOL_VERSION is manually set to \"0\".\n\nLet's fix this by lower-casing all of the header names in the trace, and\nthen checking for those in our expected code (this is easier than making\nHTTP/2 traces look like HTTP/1.1, since HTTP/1.1 uses title-casing).\n\nSadly, we can't quite do this in our existing sed script. This works if\nyou have GNU sed:\n\n  s/^\\\\([><]\\\\) \\\\([A-Za-z0-9-]*:\\\\)/\\1 \\L\\2\\E/\n\nbut \\L is a GNU-ism, and I don't think there's a portable solution. We\ncould just \"tr A-Z a-z\" on the way in, of course, but that makes the\nnon-header parts harder to read (e.g., lowercase \"post\" requests). But\nto paraphrase Baron Munchausen, I have learned from experience that a\nmodicum of Perl can be most efficacious.\n\nNote that this doesn't quite get the test passing with t5559; there are\nmore fixes needed on top.\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t5551-http-fetch-smart.sh | 55 ++++++++++++++++++++-----------------\n 1 file changed, 30 insertions(+), 25 deletions(-)\n\ndiff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh\nindex 29d489768e..a81f852cbf 100755\n--- a/t/t5551-http-fetch-smart.sh\n+++ b/t/t5551-http-fetch-smart.sh\n@@ -35,30 +35,35 @@ setup_askpass_helper\n test_expect_success 'clone http repository' '\n \tcat >exp <<-\\EOF &&\n \t> GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1\n-\t> Accept: */*\n-\t> Accept-Encoding: ENCODINGS\n-\t> Accept-Language: ko-KR, *;q=0.9\n-\t> Pragma: no-cache\n+\t> accept: */*\n+\t> accept-encoding: ENCODINGS\n+\t> accept-language: ko-KR, *;q=0.9\n+\t> pragma: no-cache\n \t< HTTP/1.1 200 OK\n-\t< Pragma: no-cache\n-\t< Cache-Control: no-cache, max-age=0, must-revalidate\n-\t< Content-Type: application/x-git-upload-pack-advertisement\n+\t< pragma: no-cache\n+\t< cache-control: no-cache, max-age=0, must-revalidate\n+\t< content-type: application/x-git-upload-pack-advertisement\n \t> POST /smart/repo.git/git-upload-pack HTTP/1.1\n-\t> Accept-Encoding: ENCODINGS\n-\t> Content-Type: application/x-git-upload-pack-request\n-\t> Accept: application/x-git-upload-pack-result\n-\t> Accept-Language: ko-KR, *;q=0.9\n-\t> Content-Length: xxx\n+\t> accept-encoding: ENCODINGS\n+\t> content-type: application/x-git-upload-pack-request\n+\t> accept: application/x-git-upload-pack-result\n+\t> accept-language: ko-KR, *;q=0.9\n+\t> content-length: xxx\n \t< HTTP/1.1 200 OK\n-\t< Pragma: no-cache\n-\t< Cache-Control: no-cache, max-age=0, must-revalidate\n-\t< Content-Type: application/x-git-upload-pack-result\n+\t< pragma: no-cache\n+\t< cache-control: no-cache, max-age=0, must-revalidate\n+\t< content-type: application/x-git-upload-pack-result\n \tEOF\n \n \tGIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION=0 LANGUAGE=\"ko_KR.UTF-8\" \\\n \t\tgit clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&\n \ttest_cmp file clone/file &&\n \ttr '\\''\\015'\\'' Q <err |\n+\tperl -pe '\\''\n+\t\ts/(Send|Recv) header: ([A-Za-z0-9-]+):/\n+\t\t\"$1 header: \" . lc($2) . \":\"\n+\t\t/e;\n+\t'\\'' |\n \tsed -e \"\n \t\ts/Q\\$//\n \t\t/^[*] /d\n@@ -78,31 +83,31 @@ test_expect_success 'clone http repository' '\n \t\t\ts/^/> /\n \t\t}\n \n-\t\t/^> User-Agent: /d\n-\t\t/^> Host: /d\n+\t\t/^> user-agent: /d\n+\t\t/^> host: /d\n \t\t/^> POST /,$ {\n \t\t\t/^> Accept: [*]\\\\/[*]/d\n \t\t}\n-\t\ts/^> Content-Length: .*/> Content-Length: xxx/\n+\t\ts/^> content-length: .*/> content-length: xxx/\n \t\t/^> 00..want /d\n \t\t/^> 00.*done/d\n \n-\t\t/^< Server: /d\n-\t\t/^< Expires: /d\n-\t\t/^< Date: /d\n-\t\t/^< Content-Length: /d\n-\t\t/^< Transfer-Encoding: /d\n+\t\t/^< server: /d\n+\t\t/^< expires: /d\n+\t\t/^< date: /d\n+\t\t/^< content-length: /d\n+\t\t/^< transfer-encoding: /d\n \t\" >actual &&\n \n \t# NEEDSWORK: If the overspecification of the expected result is reduced, we\n \t# might be able to run this test in all protocol versions.\n \tif test \"$GIT_TEST_PROTOCOL_VERSION\" = 0\n \tthen\n-\t\tsed -e \"s/^> Accept-Encoding: .*/> Accept-Encoding: ENCODINGS/\" \\\n+\t\tsed -e \"s/^> accept-encoding: .*/> accept-encoding: ENCODINGS/\" \\\n \t\t\t\tactual >actual.smudged &&\n \t\ttest_cmp exp actual.smudged &&\n \n-\t\tgrep \"Accept-Encoding:.*gzip\" actual >actual.gzip &&\n+\t\tgrep \"accept-encoding:.*gzip\" actual >actual.gzip &&\n \t\ttest_line_count = 2 actual.gzip\n \tfi\n '\n-- \n2.40.0-rc0-32-ga0f05f6840\n\n"},{"id":"472868","messageId":"20230228233913.684853-6-gitster@pobox.com","threadId":"59325","inReplyTo":"20230228233913.684853-1-gitster@pobox.com","subject":"[PATCH 06/20] t5551: handle HTTP/2 when checking curl trace","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-02-28T23:38:59Z","receivedAt":"2023-02-28T23:39:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nWe check that the curl trace of a clone has the lines we expect, but\nthis won't work when we run the test under t5559, because a few details\nare different under HTTP/2 (but nobody noticed because it only happens\nwhen you manually set GIT_TEST_PROTOCOL_VERSION to \"0\").\n\nWe can handle both HTTP protocols with a few tweaks:\n\n  - we'll drop the HTTP \"101 Switching Protocols\" response, as well as\n    various protocol upgrade headers. These details aren't interesting\n    to us. We just want to make sure the correct protocol was used (and\n    we do in the main request/response lines).\n\n  - successful HTTP/2 responses just say \"200\" and not \"200 OK\"; we can\n    normalize these\n\n  - replace HTTP/1.1 with a variable in the request/response lines. We\n    can use the existing $HTTP_PROTO for this, as it's already set to\n    \"HTTP/2\" when appropriate. We do need to tweak the fallback value to\n    \"HTTP/1.1\" to match what curl will write (prior to this patch, the\n    fallback value didn't matter at all; we only checked if it was the\n    literal string \"HTTP/2\").\n\nNote that several lines still expect HTTP/1.1 unconditionally. The first\nrequest does so because the client requests an upgrade during the\nrequest. The POST request and response do so because you can't do an\nupgrade if there is a request body. (This will all be different if we\ntrigger HTTP/2 via ALPN, but the tests aren't yet capable of that).\n\nThis is enough to let:\n\n  GIT_TEST_PROTOCOL_VERSION=0 ./t5559-http-fetch-smart-http2.sh\n\npass the \"clone http repository\" test (but there are some other failures\nlater on).\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t5551-http-fetch-smart.sh | 14 +++++++++++---\n 1 file changed, 11 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh\nindex a81f852cbf..716c9dbb69 100755\n--- a/t/t5551-http-fetch-smart.sh\n+++ b/t/t5551-http-fetch-smart.sh\n@@ -1,6 +1,6 @@\n #!/bin/sh\n \n-: ${HTTP_PROTO:=HTTP}\n+: ${HTTP_PROTO:=HTTP/1.1}\n test_description=\"test smart fetching over http via http-backend ($HTTP_PROTO)\"\n GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main\n export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n@@ -33,13 +33,13 @@ test_expect_success 'create http-accessible bare repository' '\n setup_askpass_helper\n \n test_expect_success 'clone http repository' '\n-\tcat >exp <<-\\EOF &&\n+\tcat >exp <<-EOF &&\n \t> GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1\n \t> accept: */*\n \t> accept-encoding: ENCODINGS\n \t> accept-language: ko-KR, *;q=0.9\n \t> pragma: no-cache\n-\t< HTTP/1.1 200 OK\n+\t< $HTTP_PROTO 200 OK\n \t< pragma: no-cache\n \t< cache-control: no-cache, max-age=0, must-revalidate\n \t< content-type: application/x-git-upload-pack-advertisement\n@@ -83,6 +83,14 @@ test_expect_success 'clone http repository' '\n \t\t\ts/^/> /\n \t\t}\n \n+\t\t/^< HTTP/ {\n+\t\t\ts/200$/200 OK/\n+\t\t}\n+\t\t/^< HTTP\\\\/1.1 101/d\n+\t\t/^[><] connection: /d\n+\t\t/^[><] upgrade: /d\n+\t\t/^> http2-settings: /d\n+\n \t\t/^> user-agent: /d\n \t\t/^> host: /d\n \t\t/^> POST /,$ {\n-- \n2.40.0-rc0-32-ga0f05f6840\n\n"},{"id":"472870","messageId":"20230228233913.684853-7-gitster@pobox.com","threadId":"59325","inReplyTo":"20230228233913.684853-1-gitster@pobox.com","subject":"[PATCH 07/20] t5551: stop forcing clone to run with v0 protocol","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-02-28T23:39:00Z","receivedAt":"2023-02-28T23:39:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nIn the \"clone http repository\" test, we check the curl trace to make\nsure the expected requests were made. This whole script was marked to\nhandle only the v0 protocol in d790ee1707 (tests: fix protocol version\nfor overspecifications, 2019-02-25). That makes sense, since v2 requires\nan extra request, so tests as specific as this would fail unless\nmodified.\n\nLater, in preparation for v2 becoming the default, this was tweaked by\n8a1b0978ab (test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate,\n2019-12-23). There we run the trace check only if the user has\nexplicitly asked to test protocol version 0. But it also forced the\nclone itself to run with the v0 protocol.\n\nThis makes the check for \"can we expect a v0 trace\" silly; it will\nalways be v0. But much worse, it means that the clone we are testing is\nnot like the one that normal users would run. They would use the\ndefaults, which are now v2.  And since this is supposed to be a basic\ncheck of clone-over-http, we should do the same.\n\nLet's fix this by dropping the extra v0 override. The test still passes\nbecause the trace checking only kicks in if we asked to use v0\nexplicitly (this is the same as before; even though we were running a v0\nclone, unless you specifically set GIT_TEST_PROTOCOL_VERSION=0, the\ntrace check was always skipped).\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t5551-http-fetch-smart.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh\nindex 716c9dbb69..4191174584 100755\n--- a/t/t5551-http-fetch-smart.sh\n+++ b/t/t5551-http-fetch-smart.sh\n@@ -55,7 +55,7 @@ test_expect_success 'clone http repository' '\n \t< content-type: application/x-git-upload-pack-result\n \tEOF\n \n-\tGIT_TRACE_CURL=true GIT_TEST_PROTOCOL_VERSION=0 LANGUAGE=\"ko_KR.UTF-8\" \\\n+\tGIT_TRACE_CURL=true LANGUAGE=\"ko_KR.UTF-8\" \\\n \t\tgit clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&\n \ttest_cmp file clone/file &&\n \ttr '\\''\\015'\\'' Q <err |\n-- \n2.40.0-rc0-32-ga0f05f6840\n\n"},{"id":"472871","messageId":"20230228233913.684853-8-gitster@pobox.com","threadId":"59325","inReplyTo":"20230228233913.684853-1-gitster@pobox.com","subject":"[PATCH 08/20] t5551: handle v2 protocol when checking curl trace","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-02-28T23:39:01Z","receivedAt":"2023-02-28T23:39:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nAfter cloning an http repository, we check the curl trace to make sure\nthe expected requests were made. But since the expected trace was never\nupdated to handle v2, it is only run when you ask the test suite to run\nin v0 mode (which hardly anybody does).\n\nLet's update it to handle both protocols. This isn't too hard since v2\njust sends an extra header and an extra request. So we can just annotate\nthose extra lines and strip them out for v0 (and drop the annotations\nfor v2). I didn't bother handling v1 here, as it's not really of\npractical interest (it would drop the extra v2 request, but still have\nthe \"git-protocol\" lines).\n\nThere's a similar tweak needed at the end. Since we check the\n\"accept-encoding\" value loosely, we grep for it rather than finding it\nin the verbatim trace. This grep insists that there are exactly 2\nmatches, but of course in v2 with the extra request there are 3. We\ncould tweak the number, but it's simpler still to just check that we saw\nat least one match. The verbatim check already confirmed how many\ninstances of the header we have; we're really just checking here that\n\"gzip\" is in the value (it's possible, of course, that the headers could\nhave different values, but that seems like an unlikely bug).\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t5551-http-fetch-smart.sh | 36 +++++++++++++++++++++++++-----------\n 1 file changed, 25 insertions(+), 11 deletions(-)\n\ndiff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh\nindex 4191174584..9d99cefb92 100755\n--- a/t/t5551-http-fetch-smart.sh\n+++ b/t/t5551-http-fetch-smart.sh\n@@ -33,12 +33,13 @@ test_expect_success 'create http-accessible bare repository' '\n setup_askpass_helper\n \n test_expect_success 'clone http repository' '\n-\tcat >exp <<-EOF &&\n+\tcat >exp.raw <<-EOF &&\n \t> GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1\n \t> accept: */*\n \t> accept-encoding: ENCODINGS\n \t> accept-language: ko-KR, *;q=0.9\n \t> pragma: no-cache\n+\t{V2} > git-protocol: version=2\n \t< $HTTP_PROTO 200 OK\n \t< pragma: no-cache\n \t< cache-control: no-cache, max-age=0, must-revalidate\n@@ -48,13 +49,32 @@ test_expect_success 'clone http repository' '\n \t> content-type: application/x-git-upload-pack-request\n \t> accept: application/x-git-upload-pack-result\n \t> accept-language: ko-KR, *;q=0.9\n+\t{V2} > git-protocol: version=2\n \t> content-length: xxx\n \t< HTTP/1.1 200 OK\n \t< pragma: no-cache\n \t< cache-control: no-cache, max-age=0, must-revalidate\n \t< content-type: application/x-git-upload-pack-result\n+\t{V2} > POST /smart/repo.git/git-upload-pack HTTP/1.1\n+\t{V2} > accept-encoding: ENCODINGS\n+\t{V2} > content-type: application/x-git-upload-pack-request\n+\t{V2} > accept: application/x-git-upload-pack-result\n+\t{V2} > accept-language: ko-KR, *;q=0.9\n+\t{V2} > git-protocol: version=2\n+\t{V2} > content-length: xxx\n+\t{V2} < HTTP/1.1 200 OK\n+\t{V2} < pragma: no-cache\n+\t{V2} < cache-control: no-cache, max-age=0, must-revalidate\n+\t{V2} < content-type: application/x-git-upload-pack-result\n \tEOF\n \n+\tif test \"$GIT_TEST_PROTOCOL_VERSION\" = 0\n+\tthen\n+\t\tsed \"/^{V2}/d\" <exp.raw >exp\n+\telse\n+\t\tsed \"s/^{V2} //\" <exp.raw >exp\n+\tfi &&\n+\n \tGIT_TRACE_CURL=true LANGUAGE=\"ko_KR.UTF-8\" \\\n \t\tgit clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&\n \ttest_cmp file clone/file &&\n@@ -107,17 +127,11 @@ test_expect_success 'clone http repository' '\n \t\t/^< transfer-encoding: /d\n \t\" >actual &&\n \n-\t# NEEDSWORK: If the overspecification of the expected result is reduced, we\n-\t# might be able to run this test in all protocol versions.\n-\tif test \"$GIT_TEST_PROTOCOL_VERSION\" = 0\n-\tthen\n-\t\tsed -e \"s/^> accept-encoding: .*/> accept-encoding: ENCODINGS/\" \\\n-\t\t\t\tactual >actual.smudged &&\n-\t\ttest_cmp exp actual.smudged &&\n+\tsed -e \"s/^> accept-encoding: .*/> accept-encoding: ENCODINGS/\" \\\n+\t\t\tactual >actual.smudged &&\n+\ttest_cmp exp actual.smudged &&\n \n-\t\tgrep \"accept-encoding:.*gzip\" actual >actual.gzip &&\n-\t\ttest_line_count = 2 actual.gzip\n-\tfi\n+\tgrep \"accept-encoding:.*gzip\" actual >actual.gzip\n '\n \n test_expect_success 'fetch changes via http' '\n-- \n2.40.0-rc0-32-ga0f05f6840\n\n"},{"id":"472872","messageId":"20230228233913.684853-9-gitster@pobox.com","threadId":"59325","inReplyTo":"20230228233913.684853-1-gitster@pobox.com","subject":"[PATCH 09/20] t5551: handle v2 protocol in upload-pack service test","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-02-28T23:39:02Z","receivedAt":"2023-02-28T23:39:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Jeff King <peff@peff.net>\n\nWe perform a clone and a fetch, and then check that we saw the expected\nrequests in Apache's access log. In the v2 protocol, there will be one\nextra request to /git-upload-pack for each operation (since the initial\n/info/refs probe is just used to upgrade the protocol).\n\nAs a result, this test is a noop unless the use of the v0 protocol is\nforced. Which means that hardly anybody runs it, since you have to do so\nmanually.\n\nLet's update it to handle v2 and run it always. We could do this by just\nconditionally adding in the extra POST lines. But if we look at the\norigin of the test in 7da4e2280c (test smart http fetch and push,\n2009-10-30), the point is really just to make sure that the smart\ngit-upload-pack service was used at all. So rather than counting up the\nindividual requests, let's just make sure we saw each of the expected\ntypes. This is a bit looser, but makes maintenance easier.\n\nSince we're now matching with grep, we can also loosen the HTTP/1.1\nmatch, which allows this test to pass when run with HTTP/2 via t5559.\nThat lets:\n\n  GIT_TEST_PROTOCOL_VERSION=0 ./t5559-http-fetch-smart-http2.sh\n\nrun to completion, which previously failed (and of course it works if\nyou use v2, as well).\n\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t5551-http-fetch-smart.sh | 16 +++-------------\n 1 file changed, 3 insertions(+), 13 deletions(-)\n\ndiff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh\nindex 9d99cefb92..b912958518 100755\n--- a/t/t5551-http-fetch-smart.sh\n+++ b/t/t5551-http-fetch-smart.sh\n@@ -143,19 +143,9 @@ test_expect_success 'fetch changes via http' '\n '\n \n test_expect_success 'used upload-pack service' '\n-\tcat >exp <<-\\EOF &&\n-\tGET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n-\tPOST /smart/repo.git/git-upload-pack HTTP/1.1 200\n-\tGET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n-\tPOST /smart/repo.git/git-upload-pack HTTP/1.1 200\n-\tEOF\n-\n-\t# NEEDSWORK: If the overspecification of the expected result is reduced, we\n-\t# might be able to run this test in all protocol versions.\n-\tif test \"$GIT_TEST_PROTOCOL_VERSION\" = 0\n-\tthen\n-\t\tcheck_access_log exp\n-\tfi\n+\tstrip_access_log >log &&\n+\tgrep \"GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/[0-9.]* 200\" log &&\n+\tgrep \"POST /smart/repo.git/git-upload-pack HTTP/[0-9.]* 200\" log\n '\n \n test_expect_success 'follow redirects (301)' '\n-- \n2.40.0-rc0-32-ga0f05f6840\n\n"},{"id":"472873","messageId":"xmqqlekhpddm.fsf@gitster.g","threadId":"59325","inReplyTo":"20230228233913.684853-1-gitster@pobox.com","subject":"Re: [PATCH 01/20] t5541: run \"used receive-pack service\" test earlier","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-02-28T23:40:53Z","receivedAt":"2023-02-28T23:40:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> From: Jeff King <peff@peff.net>\n\nSorry for these patches that were sent out by accident.  Please\ndisregard.\n"}]}