{"thread":{"id":"22042","subject":"[PATCH RFC 1/2] Smart-http tests: Break test t5560-http-backend into pieces","startedAt":"2009-12-28T22:04:58Z","lastAt":"2010-01-21T16:15:42Z","messageCount":31,"participants":["Tarmigan Casebolt","Junio C Hamano","Tarmigan","Shawn O. Pearce","Michael Haggerty","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"130423","messageId":"1262037899-16786-1-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":null,"subject":"[PATCH RFC 1/2] Smart-http tests: Break test t5560-http-backend into pieces","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2009-12-28T22:04:58Z","receivedAt":"2009-12-28T22:04:58Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"This should introduce no functional change in the tests or the amount\nof test coverage.\n\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n---\n t/t5560-http-backend.sh          |  135 +-------------------------------------\n t/t5561-http-backend-noserver.sh |   52 +++++++++++++++\n t/t556x_common                   |  105 +++++++++++++++++++++++++++++\n 3 files changed, 158 insertions(+), 134 deletions(-)\n create mode 100755 t/t5561-http-backend-noserver.sh\n create mode 100755 t/t556x_common\n\ndiff --git a/t/t5560-http-backend.sh b/t/t5560-http-backend.sh\nindex ed034bc..b0d08e2 100755\n--- a/t/t5560-http-backend.sh\n+++ b/t/t5560-http-backend.sh\n@@ -12,16 +12,6 @@ LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5560'}\n . \"$TEST_DIRECTORY\"/lib-httpd.sh\n start_httpd\n \n-find_file() {\n-\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\tfind $1 -type f |\n-\tsed -e 1q\n-}\n-\n-config() {\n-\tgit --git-dir=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" config $1 $2\n-}\n-\n GET() {\n \tcurl --include \"$HTTPD_URL/smart/repo.git/$1\" >out 2>/dev/null &&\n \ttr '\\015' Q <out |\n@@ -52,130 +42,7 @@ log_div() {\n \techo \"###\" >>\"$HTTPD_ROOT_PATH\"/access.log\n }\n \n-test_expect_success 'setup repository' '\n-\techo content >file &&\n-\tgit add file &&\n-\tgit commit -m one &&\n-\n-\tmkdir \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t git --bare init &&\n-\t : >objects/info/alternates &&\n-\t : >objects/info/http-alternates\n-\t) &&\n-\tgit remote add public \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\tgit push public master:master &&\n-\n-\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t git repack -a -d\n-\t) &&\n-\n-\techo other >file &&\n-\tgit add file &&\n-\tgit commit -m two &&\n-\tgit push public master:master &&\n-\n-\tLOOSE_URL=$(find_file objects/??) &&\n-\tPACK_URL=$(find_file objects/pack/*.pack) &&\n-\tIDX_URL=$(find_file objects/pack/*.idx)\n-'\n-\n-get_static_files() {\n-\tGET HEAD \"$1\" &&\n-\tGET info/refs \"$1\" &&\n-\tGET objects/info/packs \"$1\" &&\n-\tGET objects/info/alternates \"$1\" &&\n-\tGET objects/info/http-alternates \"$1\" &&\n-\tGET $LOOSE_URL \"$1\" &&\n-\tGET $PACK_URL \"$1\" &&\n-\tGET $IDX_URL \"$1\"\n-}\n-\n-test_expect_success 'direct refs/heads/master not found' '\n-\tlog_div \"refs/heads/master\"\n-\tGET refs/heads/master \"404 Not Found\"\n-'\n-test_expect_success 'static file is ok' '\n-\tlog_div \"getanyfile default\"\n-\tget_static_files \"200 OK\"\n-'\n-test_expect_success 'static file if http.getanyfile true is ok' '\n-\tlog_div \"getanyfile true\"\n-\tconfig http.getanyfile true &&\n-\tget_static_files \"200 OK\"\n-'\n-test_expect_success 'static file if http.getanyfile false fails' '\n-\tlog_div \"getanyfile false\"\n-\tconfig http.getanyfile false &&\n-\tget_static_files \"403 Forbidden\"\n-'\n-\n-test_expect_success 'http.uploadpack default enabled' '\n-\tlog_div \"uploadpack default\"\n-\tGET info/refs?service=git-upload-pack \"200 OK\"  &&\n-\tPOST git-upload-pack 0000 \"200 OK\"\n-'\n-test_expect_success 'http.uploadpack true' '\n-\tlog_div \"uploadpack true\"\n-\tconfig http.uploadpack true &&\n-\tGET info/refs?service=git-upload-pack \"200 OK\" &&\n-\tPOST git-upload-pack 0000 \"200 OK\"\n-'\n-test_expect_success 'http.uploadpack false' '\n-\tlog_div \"uploadpack false\"\n-\tconfig http.uploadpack false &&\n-\tGET info/refs?service=git-upload-pack \"403 Forbidden\" &&\n-\tPOST git-upload-pack 0000 \"403 Forbidden\"\n-'\n-\n-test_expect_success 'http.receivepack default disabled' '\n-\tlog_div \"receivepack default\"\n-\tGET info/refs?service=git-receive-pack \"403 Forbidden\"  &&\n-\tPOST git-receive-pack 0000 \"403 Forbidden\"\n-'\n-test_expect_success 'http.receivepack true' '\n-\tlog_div \"receivepack true\"\n-\tconfig http.receivepack true &&\n-\tGET info/refs?service=git-receive-pack \"200 OK\" &&\n-\tPOST git-receive-pack 0000 \"200 OK\"\n-'\n-test_expect_success 'http.receivepack false' '\n-\tlog_div \"receivepack false\"\n-\tconfig http.receivepack false &&\n-\tGET info/refs?service=git-receive-pack \"403 Forbidden\" &&\n-\tPOST git-receive-pack 0000 \"403 Forbidden\"\n-'\n-\n-run_backend() {\n-\tREQUEST_METHOD=GET \\\n-\tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n-\tPATH_INFO=\"$2\" \\\n-\tgit http-backend >act.out 2>act.err\n-}\n-\n-path_info() {\n-\tif test $1 = 0; then\n-\t\trun_backend \"$2\"\n-\telse\n-\t\ttest_must_fail run_backend \"$2\" &&\n-\t\techo \"fatal: '$2': aliased\" >exp.err &&\n-\t\ttest_cmp exp.err act.err\n-\tfi\n-}\n-\n-test_expect_success 'http-backend blocks bad PATH_INFO' '\n-\tconfig http.getanyfile true &&\n-\n-\trun_backend 0 /repo.git/HEAD &&\n-\n-\trun_backend 1 /repo.git/../HEAD &&\n-\trun_backend 1 /../etc/passwd &&\n-\trun_backend 1 ../etc/passwd &&\n-\trun_backend 1 /etc//passwd &&\n-\trun_backend 1 /etc/./passwd &&\n-\trun_backend 1 /etc/.../passwd &&\n-\trun_backend 1 //domain/data.txt\n-'\n+. \"$TEST_DIRECTORY\"/t556x_common\n \n cat >exp <<EOF\n \ndiff --git a/t/t5561-http-backend-noserver.sh b/t/t5561-http-backend-noserver.sh\nnew file mode 100755\nindex 0000000..501b328\n--- /dev/null\n+++ b/t/t5561-http-backend-noserver.sh\n@@ -0,0 +1,52 @@\n+#!/bin/sh\n+\n+test_description='test git-http-backend-noserver'\n+. ./test-lib.sh\n+\n+HTTPD_DOCUMENT_ROOT_PATH=\"$TRASH_DIRECTORY\"\n+\n+GET() {\n+    return 0\n+}\n+\n+POST() {\n+    return 0\n+}\n+\n+logdiv() {\n+    return 0\n+}\n+\n+. \"$TEST_DIRECTORY\"/t556x_common\n+\n+run_backend() {\n+\tREQUEST_METHOD=GET \\\n+\tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n+\tPATH_INFO=\"$2\" \\\n+\tgit http-backend >act.out 2>act.err\n+}\n+\n+path_info() {\n+\tif test $1 = 0; then\n+\t\trun_backend \"$2\"\n+\telse\n+\t\ttest_must_fail run_backend \"$2\" &&\n+\t\techo \"fatal: '$2': aliased\" >exp.err &&\n+\t\ttest_cmp exp.err act.err\n+\tfi\n+}\n+\n+test_expect_success 'http-backend blocks bad PATH_INFO' '\n+\tconfig http.getanyfile true &&\n+\n+\trun_backend 0 /repo.git/HEAD &&\n+\n+\trun_backend 1 /repo.git/../HEAD &&\n+\trun_backend 1 /../etc/passwd &&\n+\trun_backend 1 ../etc/passwd &&\n+\trun_backend 1 /etc//passwd &&\n+\trun_backend 1 /etc/./passwd &&\n+\trun_backend 1 /etc/.../passwd &&\n+\trun_backend 1 //domain/data.txt\n+'\n+test_done\ndiff --git a/t/t556x_common b/t/t556x_common\nnew file mode 100755\nindex 0000000..1845072\n--- /dev/null\n+++ b/t/t556x_common\n@@ -0,0 +1,105 @@\n+#!/bin/sh\n+\n+find_file() {\n+\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\tfind $1 -type f |\n+\tsed -e 1q\n+}\n+\n+config() {\n+\tgit --git-dir=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" config $1 $2\n+}\n+\n+test_expect_success 'setup repository' '\n+\techo content >file &&\n+\tgit add file &&\n+\tgit commit -m one &&\n+\n+\tmkdir \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t git --bare init &&\n+\t : >objects/info/alternates &&\n+\t : >objects/info/http-alternates\n+\t) &&\n+\tgit remote add public \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\tgit push public master:master &&\n+\n+\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t git repack -a -d\n+\t) &&\n+\n+\techo other >file &&\n+\tgit add file &&\n+\tgit commit -m two &&\n+\tgit push public master:master &&\n+\n+\tLOOSE_URL=$(find_file objects/??) &&\n+\tPACK_URL=$(find_file objects/pack/*.pack) &&\n+\tIDX_URL=$(find_file objects/pack/*.idx)\n+'\n+\n+get_static_files() {\n+\tGET HEAD \"$1\" &&\n+\tGET info/refs \"$1\" &&\n+\tGET objects/info/packs \"$1\" &&\n+\tGET objects/info/alternates \"$1\" &&\n+\tGET objects/info/http-alternates \"$1\" &&\n+\tGET $LOOSE_URL \"$1\" &&\n+\tGET $PACK_URL \"$1\" &&\n+\tGET $IDX_URL \"$1\"\n+}\n+\n+test_expect_success 'direct refs/heads/master not found' '\n+\tlog_div \"refs/heads/master\"\n+\tGET refs/heads/master \"404 Not Found\"\n+'\n+test_expect_success 'static file is ok' '\n+\tlog_div \"getanyfile default\"\n+\tget_static_files \"200 OK\"\n+'\n+test_expect_success 'static file if http.getanyfile true is ok' '\n+\tlog_div \"getanyfile true\"\n+\tconfig http.getanyfile true &&\n+\tget_static_files \"200 OK\"\n+'\n+test_expect_success 'static file if http.getanyfile false fails' '\n+\tlog_div \"getanyfile false\"\n+\tconfig http.getanyfile false &&\n+\tget_static_files \"403 Forbidden\"\n+'\n+\n+test_expect_success 'http.uploadpack default enabled' '\n+\tlog_div \"uploadpack default\"\n+\tGET info/refs?service=git-upload-pack \"200 OK\"  &&\n+\tPOST git-upload-pack 0000 \"200 OK\"\n+'\n+test_expect_success 'http.uploadpack true' '\n+\tlog_div \"uploadpack true\"\n+\tconfig http.uploadpack true &&\n+\tGET info/refs?service=git-upload-pack \"200 OK\" &&\n+\tPOST git-upload-pack 0000 \"200 OK\"\n+'\n+test_expect_success 'http.uploadpack false' '\n+\tlog_div \"uploadpack false\"\n+\tconfig http.uploadpack false &&\n+\tGET info/refs?service=git-upload-pack \"403 Forbidden\" &&\n+\tPOST git-upload-pack 0000 \"403 Forbidden\"\n+'\n+\n+test_expect_success 'http.receivepack default disabled' '\n+\tlog_div \"receivepack default\"\n+\tGET info/refs?service=git-receive-pack \"403 Forbidden\"  &&\n+\tPOST git-receive-pack 0000 \"403 Forbidden\"\n+'\n+test_expect_success 'http.receivepack true' '\n+\tlog_div \"receivepack true\"\n+\tconfig http.receivepack true &&\n+\tGET info/refs?service=git-receive-pack \"200 OK\" &&\n+\tPOST git-receive-pack 0000 \"200 OK\"\n+'\n+test_expect_success 'http.receivepack false' '\n+\tlog_div \"receivepack false\"\n+\tconfig http.receivepack false &&\n+\tGET info/refs?service=git-receive-pack \"403 Forbidden\" &&\n+\tPOST git-receive-pack 0000 \"403 Forbidden\"\n+'\n-- \n1.6.6.62.g67314\n"},{"id":"130424","messageId":"1262037899-16786-2-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":"1262037899-16786-1-git-send-email-tarmigan+git@gmail.com","subject":"[PATCH RFC 2/2] Smart-http tests: Test http-backend without curl or a webserver","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2009-12-28T22:04:59Z","receivedAt":"2009-12-28T22:04:59Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"This reuses many of the tests from t5560 but runs those tests without curl\nor a webserver.  This will hopefully increase the testing coverage for\nhttp-backend because it does not require users to set GIT_TEST_HTTPD.\n\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n---\n t/t5561-http-backend-noserver.sh |   45 ++++++++++++++++++++++----------------\n 1 files changed, 26 insertions(+), 19 deletions(-)\n\ndiff --git a/t/t5561-http-backend-noserver.sh b/t/t5561-http-backend-noserver.sh\nindex 501b328..6371e97 100755\n--- a/t/t5561-http-backend-noserver.sh\n+++ b/t/t5561-http-backend-noserver.sh\n@@ -5,12 +5,35 @@ test_description='test git-http-backend-noserver'\n \n HTTPD_DOCUMENT_ROOT_PATH=\"$TRASH_DIRECTORY\"\n \n+run_backend() {\n+        echo \"$3\"| \\\n+        QUERY_STRING=\"${2#*\\?}\" \\\n+\tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n+\tPATH_INFO=\"${2%%\\?*}\" \\\n+\tgit http-backend >act.out 2>act.err\n+}\n+\n GET() {\n-    return 0\n+    REQUEST_METHOD=\"GET\" \\\n+    run_backend 0 \"/repo.git/$1\" &&\n+    grep \"Status\" act.out >act\n+    if [ $? -ne 1 ];\n+    then\n+\tprintf \"Status: $2\\r\\n\" > exp &&\n+\ttest_cmp exp act\n+    fi\n }\n \n POST() {\n-    return 0\n+    REQUEST_METHOD=\"POST\" \\\n+    CONTENT_TYPE=\"application/x-$1-request\" \\\n+    run_backend 0 \"/repo.git/$1\" \"$2\" &&\n+    grep \"Status\" act.out >act\n+    if [ $? -ne 1 ];\n+    then\n+\tprintf \"Status: $3\\r\\n\" > exp &&\n+\ttest_cmp exp act\n+    fi\n }\n \n logdiv() {\n@@ -19,26 +42,10 @@ logdiv() {\n \n . \"$TEST_DIRECTORY\"/t556x_common\n \n-run_backend() {\n-\tREQUEST_METHOD=GET \\\n-\tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n-\tPATH_INFO=\"$2\" \\\n-\tgit http-backend >act.out 2>act.err\n-}\n-\n-path_info() {\n-\tif test $1 = 0; then\n-\t\trun_backend \"$2\"\n-\telse\n-\t\ttest_must_fail run_backend \"$2\" &&\n-\t\techo \"fatal: '$2': aliased\" >exp.err &&\n-\t\ttest_cmp exp.err act.err\n-\tfi\n-}\n-\n test_expect_success 'http-backend blocks bad PATH_INFO' '\n \tconfig http.getanyfile true &&\n \n+\tREQUEST_METHOD=\"GET\" &&\n \trun_backend 0 /repo.git/HEAD &&\n \n \trun_backend 1 /repo.git/../HEAD &&\n-- \n1.6.6.62.g67314\n"},{"id":"130566","messageId":"7veimc2vq0.fsf@alter.siamese.dyndns.org","threadId":"22042","inReplyTo":"1262037899-16786-1-git-send-email-tarmigan+git@gmail.com","subject":"Re: [PATCH RFC 1/2] Smart-http tests: Break test t5560-http-backend into pieces","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-30T17:54:47Z","receivedAt":"2009-12-30T17:54:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tarmigan Casebolt <tarmigan+git@gmail.com> writes:\n\n> This should introduce no functional change in the tests or the amount\n> of test coverage.\n>\n> Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n\nThis seems to crash rather badly with your own \"Smart-http: check if\nrepository is OK to export before serving it\".\n"},{"id":"130569","messageId":"905315640912301009x491f957al839f66de7aba56ed@mail.gmail.com","threadId":"22042","inReplyTo":"7veimc2vq0.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH RFC 1/2] Smart-http tests: Break test t5560-http-backend into pieces","fromName":"Tarmigan","fromEmail":"tarmigan+git@gmail.com","sentAt":"2009-12-30T18:09:38Z","receivedAt":"2009-12-30T18:09:38Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"On Wed, Dec 30, 2009 at 12:54 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Tarmigan Casebolt <tarmigan+git@gmail.com> writes:\n>\n>> This should introduce no functional change in the tests or the amount\n>> of test coverage.\n>>\n>> Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n>\n> This seems to crash rather badly with your own \"Smart-http: check if\n> repository is OK to export before serving it\".\n\nYes, they were both separately based on 'master' a few days ago.\n\nIf you think the goal (more about that is in the commit log of 2/2) is\nworthwhile, I am happy to rebase on top of pu and resend.\n\nOne reason it's labeled RFC is that I'm not very confident in my\nability to write portable shell script.  It works for me with bash,\nbut I'm not completely confident that is would work on ksh or dash.\nSo it would be nice if you could specifically take a look at the new\nPOST() and GET() and see if you notice anything obviously wrong there.\n\nThanks,\nTarmigan\n"},{"id":"130571","messageId":"1262199542-73876-1-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":"905315640912301009x491f957al839f66de7aba56ed@mail.gmail.com","subject":"[PATCH RFC 1/2] Smart-http tests: Break test t5560-http-backend into pieces","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2009-12-30T18:59:01Z","receivedAt":"2009-12-30T18:59:01Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"This should introduce no functional change in the tests or the amount\nof test coverage.\n\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n---\nThis is rebased on top of today's pu and the conflicts should be fixed.\n\n t/t5560-http-backend.sh          |  148 +-------------------------------------\n t/t5561-http-backend-noserver.sh |   52 +++++++++++++\n t/t556x_common                   |  119 ++++++++++++++++++++++++++++++\n 3 files changed, 172 insertions(+), 147 deletions(-)\n create mode 100755 t/t5561-http-backend-noserver.sh\n create mode 100755 t/t556x_common\n\ndiff --git a/t/t5560-http-backend.sh b/t/t5560-http-backend.sh\nindex 04a9896..dd844d3 100755\n--- a/t/t5560-http-backend.sh\n+++ b/t/t5560-http-backend.sh\n@@ -12,16 +12,6 @@ LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5560'}\n . \"$TEST_DIRECTORY\"/lib-httpd.sh\n start_httpd\n \n-find_file() {\n-\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\tfind $1 -type f |\n-\tsed -e 1q\n-}\n-\n-config() {\n-\tgit --git-dir=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" config $1 $2\n-}\n-\n GET() {\n \tcurl --include \"$HTTPD_URL/$SMART/repo.git/$1\" >out 2>/dev/null &&\n \ttr '\\015' Q <out |\n@@ -52,143 +42,7 @@ log_div() {\n \techo \"###\" >>\"$HTTPD_ROOT_PATH\"/access.log\n }\n \n-test_expect_success 'setup repository' '\n-\techo content >file &&\n-\tgit add file &&\n-\tgit commit -m one &&\n-\n-\tmkdir \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t git --bare init &&\n-\t : >objects/info/alternates &&\n-\t : >objects/info/http-alternates\n-\t) &&\n-\tgit remote add public \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\tgit push public master:master &&\n-\n-\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t git repack -a -d\n-\t) &&\n-\n-\techo other >file &&\n-\tgit add file &&\n-\tgit commit -m two &&\n-\tgit push public master:master &&\n-\n-\tLOOSE_URL=$(find_file objects/??) &&\n-\tPACK_URL=$(find_file objects/pack/*.pack) &&\n-\tIDX_URL=$(find_file objects/pack/*.idx)\n-'\n-\n-get_static_files() {\n-\tGET HEAD \"$1\" &&\n-\tGET info/refs \"$1\" &&\n-\tGET objects/info/packs \"$1\" &&\n-\tGET objects/info/alternates \"$1\" &&\n-\tGET objects/info/http-alternates \"$1\" &&\n-\tGET $LOOSE_URL \"$1\" &&\n-\tGET $PACK_URL \"$1\" &&\n-\tGET $IDX_URL \"$1\"\n-}\n-\n-SMART=smart\n-test_expect_success 'direct refs/heads/master not found' '\n-\tlog_div \"refs/heads/master\"\n-\tGET refs/heads/master \"404 Not Found\"\n-'\n-test_expect_success 'static file is ok' '\n-\tlog_div \"getanyfile default\"\n-\tget_static_files \"200 OK\"\n-'\n-SMART=smart_noexport\n-test_expect_success 'no export by default' '\n-\tlog_div \"no git-daemon-export-ok\"\n-\tget_static_files \"404 Not Found\"\n-'\n-test_expect_success 'export if git-daemon-export-ok' '\n-\tlog_div \"git-daemon-export-ok\"\n-        (cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t touch git-daemon-export-ok\n-\t) &&\n-        get_static_files \"200 OK\"\n-'\n-SMART=smart\n-test_expect_success 'static file if http.getanyfile true is ok' '\n-\tlog_div \"getanyfile true\"\n-\tconfig http.getanyfile true &&\n-\tget_static_files \"200 OK\"\n-'\n-test_expect_success 'static file if http.getanyfile false fails' '\n-\tlog_div \"getanyfile false\"\n-\tconfig http.getanyfile false &&\n-\tget_static_files \"403 Forbidden\"\n-'\n-\n-test_expect_success 'http.uploadpack default enabled' '\n-\tlog_div \"uploadpack default\"\n-\tGET info/refs?service=git-upload-pack \"200 OK\"  &&\n-\tPOST git-upload-pack 0000 \"200 OK\"\n-'\n-test_expect_success 'http.uploadpack true' '\n-\tlog_div \"uploadpack true\"\n-\tconfig http.uploadpack true &&\n-\tGET info/refs?service=git-upload-pack \"200 OK\" &&\n-\tPOST git-upload-pack 0000 \"200 OK\"\n-'\n-test_expect_success 'http.uploadpack false' '\n-\tlog_div \"uploadpack false\"\n-\tconfig http.uploadpack false &&\n-\tGET info/refs?service=git-upload-pack \"403 Forbidden\" &&\n-\tPOST git-upload-pack 0000 \"403 Forbidden\"\n-'\n-\n-test_expect_success 'http.receivepack default disabled' '\n-\tlog_div \"receivepack default\"\n-\tGET info/refs?service=git-receive-pack \"403 Forbidden\"  &&\n-\tPOST git-receive-pack 0000 \"403 Forbidden\"\n-'\n-test_expect_success 'http.receivepack true' '\n-\tlog_div \"receivepack true\"\n-\tconfig http.receivepack true &&\n-\tGET info/refs?service=git-receive-pack \"200 OK\" &&\n-\tPOST git-receive-pack 0000 \"200 OK\"\n-'\n-test_expect_success 'http.receivepack false' '\n-\tlog_div \"receivepack false\"\n-\tconfig http.receivepack false &&\n-\tGET info/refs?service=git-receive-pack \"403 Forbidden\" &&\n-\tPOST git-receive-pack 0000 \"403 Forbidden\"\n-'\n-run_backend() {\n-\tREQUEST_METHOD=GET \\\n-\tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n-\tPATH_INFO=\"$2\" \\\n-\tgit http-backend >act.out 2>act.err\n-}\n-\n-path_info() {\n-\tif test $1 = 0; then\n-\t\trun_backend \"$2\"\n-\telse\n-\t\ttest_must_fail run_backend \"$2\" &&\n-\t\techo \"fatal: '$2': aliased\" >exp.err &&\n-\t\ttest_cmp exp.err act.err\n-\tfi\n-}\n-\n-test_expect_success 'http-backend blocks bad PATH_INFO' '\n-\tconfig http.getanyfile true &&\n-\n-\trun_backend 0 /repo.git/HEAD &&\n-\n-\trun_backend 1 /repo.git/../HEAD &&\n-\trun_backend 1 /../etc/passwd &&\n-\trun_backend 1 ../etc/passwd &&\n-\trun_backend 1 /etc//passwd &&\n-\trun_backend 1 /etc/./passwd &&\n-\trun_backend 1 /etc/.../passwd &&\n-\trun_backend 1 //domain/data.txt\n-'\n+. \"$TEST_DIRECTORY\"/t556x_common\n \n cat >exp <<EOF\n \ndiff --git a/t/t5561-http-backend-noserver.sh b/t/t5561-http-backend-noserver.sh\nnew file mode 100755\nindex 0000000..501b328\n--- /dev/null\n+++ b/t/t5561-http-backend-noserver.sh\n@@ -0,0 +1,52 @@\n+#!/bin/sh\n+\n+test_description='test git-http-backend-noserver'\n+. ./test-lib.sh\n+\n+HTTPD_DOCUMENT_ROOT_PATH=\"$TRASH_DIRECTORY\"\n+\n+GET() {\n+    return 0\n+}\n+\n+POST() {\n+    return 0\n+}\n+\n+logdiv() {\n+    return 0\n+}\n+\n+. \"$TEST_DIRECTORY\"/t556x_common\n+\n+run_backend() {\n+\tREQUEST_METHOD=GET \\\n+\tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n+\tPATH_INFO=\"$2\" \\\n+\tgit http-backend >act.out 2>act.err\n+}\n+\n+path_info() {\n+\tif test $1 = 0; then\n+\t\trun_backend \"$2\"\n+\telse\n+\t\ttest_must_fail run_backend \"$2\" &&\n+\t\techo \"fatal: '$2': aliased\" >exp.err &&\n+\t\ttest_cmp exp.err act.err\n+\tfi\n+}\n+\n+test_expect_success 'http-backend blocks bad PATH_INFO' '\n+\tconfig http.getanyfile true &&\n+\n+\trun_backend 0 /repo.git/HEAD &&\n+\n+\trun_backend 1 /repo.git/../HEAD &&\n+\trun_backend 1 /../etc/passwd &&\n+\trun_backend 1 ../etc/passwd &&\n+\trun_backend 1 /etc//passwd &&\n+\trun_backend 1 /etc/./passwd &&\n+\trun_backend 1 /etc/.../passwd &&\n+\trun_backend 1 //domain/data.txt\n+'\n+test_done\ndiff --git a/t/t556x_common b/t/t556x_common\nnew file mode 100755\nindex 0000000..1b4921c\n--- /dev/null\n+++ b/t/t556x_common\n@@ -0,0 +1,119 @@\n+#!/bin/sh\n+\n+find_file() {\n+\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\tfind $1 -type f |\n+\tsed -e 1q\n+}\n+\n+config() {\n+\tgit --git-dir=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" config $1 $2\n+}\n+\n+test_expect_success 'setup repository' '\n+\techo content >file &&\n+\tgit add file &&\n+\tgit commit -m one &&\n+\n+\tmkdir \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t git --bare init &&\n+\t : >objects/info/alternates &&\n+\t : >objects/info/http-alternates\n+\t) &&\n+\tgit remote add public \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\tgit push public master:master &&\n+\n+\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t git repack -a -d\n+\t) &&\n+\n+\techo other >file &&\n+\tgit add file &&\n+\tgit commit -m two &&\n+\tgit push public master:master &&\n+\n+\tLOOSE_URL=$(find_file objects/??) &&\n+\tPACK_URL=$(find_file objects/pack/*.pack) &&\n+\tIDX_URL=$(find_file objects/pack/*.idx)\n+'\n+\n+get_static_files() {\n+\tGET HEAD \"$1\" &&\n+\tGET info/refs \"$1\" &&\n+\tGET objects/info/packs \"$1\" &&\n+\tGET objects/info/alternates \"$1\" &&\n+\tGET objects/info/http-alternates \"$1\" &&\n+\tGET $LOOSE_URL \"$1\" &&\n+\tGET $PACK_URL \"$1\" &&\n+\tGET $IDX_URL \"$1\"\n+}\n+\n+SMART=smart\n+test_expect_success 'direct refs/heads/master not found' '\n+\tlog_div \"refs/heads/master\"\n+\tGET refs/heads/master \"404 Not Found\"\n+'\n+test_expect_success 'static file is ok' '\n+\tlog_div \"getanyfile default\"\n+\tget_static_files \"200 OK\"\n+'\n+SMART=smart_noexport\n+test_expect_success 'no export by default' '\n+\tlog_div \"no git-daemon-export-ok\"\n+\tget_static_files \"404 Not Found\"\n+'\n+test_expect_success 'export if git-daemon-export-ok' '\n+\tlog_div \"git-daemon-export-ok\"\n+        (cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t touch git-daemon-export-ok\n+\t) &&\n+        get_static_files \"200 OK\"\n+'\n+SMART=smart\n+test_expect_success 'static file if http.getanyfile true is ok' '\n+\tlog_div \"getanyfile true\"\n+\tconfig http.getanyfile true &&\n+\tget_static_files \"200 OK\"\n+'\n+test_expect_success 'static file if http.getanyfile false fails' '\n+\tlog_div \"getanyfile false\"\n+\tconfig http.getanyfile false &&\n+\tget_static_files \"403 Forbidden\"\n+'\n+\n+test_expect_success 'http.uploadpack default enabled' '\n+\tlog_div \"uploadpack default\"\n+\tGET info/refs?service=git-upload-pack \"200 OK\"  &&\n+\tPOST git-upload-pack 0000 \"200 OK\"\n+'\n+test_expect_success 'http.uploadpack true' '\n+\tlog_div \"uploadpack true\"\n+\tconfig http.uploadpack true &&\n+\tGET info/refs?service=git-upload-pack \"200 OK\" &&\n+\tPOST git-upload-pack 0000 \"200 OK\"\n+'\n+test_expect_success 'http.uploadpack false' '\n+\tlog_div \"uploadpack false\"\n+\tconfig http.uploadpack false &&\n+\tGET info/refs?service=git-upload-pack \"403 Forbidden\" &&\n+\tPOST git-upload-pack 0000 \"403 Forbidden\"\n+'\n+\n+test_expect_success 'http.receivepack default disabled' '\n+\tlog_div \"receivepack default\"\n+\tGET info/refs?service=git-receive-pack \"403 Forbidden\"  &&\n+\tPOST git-receive-pack 0000 \"403 Forbidden\"\n+'\n+test_expect_success 'http.receivepack true' '\n+\tlog_div \"receivepack true\"\n+\tconfig http.receivepack true &&\n+\tGET info/refs?service=git-receive-pack \"200 OK\" &&\n+\tPOST git-receive-pack 0000 \"200 OK\"\n+'\n+test_expect_success 'http.receivepack false' '\n+\tlog_div \"receivepack false\"\n+\tconfig http.receivepack false &&\n+\tGET info/refs?service=git-receive-pack \"403 Forbidden\" &&\n+\tPOST git-receive-pack 0000 \"403 Forbidden\"\n+'\n-- \n1.6.6\n"},{"id":"130572","messageId":"1262199542-73876-2-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":"1262199542-73876-1-git-send-email-tarmigan+git@gmail.com","subject":"[PATCH RFC 2/2] Smart-http tests: Test http-backend without curl or a webserver","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2009-12-30T18:59:02Z","receivedAt":"2009-12-30T18:59:02Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"This reuses many of the tests from t5560 but runs those tests without curl\nor a webserver.  This will hopefully increase the testing coverage for\nhttp-backend because it does not require users to set GIT_TEST_HTTPD.\n\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n---\nIn addition to the rebase, I fixed a bunch of bugs in this version.  I'm\nstill leaving this as RFC as there may be some more.\n\n t/t5561-http-backend-noserver.sh |   49 ++++++++++++++++++++++---------------\n t/t556x_common                   |    3 ++\n 2 files changed, 32 insertions(+), 20 deletions(-)\n\ndiff --git a/t/t5561-http-backend-noserver.sh b/t/t5561-http-backend-noserver.sh\nindex 501b328..bda5029 100755\n--- a/t/t5561-http-backend-noserver.sh\n+++ b/t/t5561-http-backend-noserver.sh\n@@ -5,40 +5,49 @@ test_description='test git-http-backend-noserver'\n \n HTTPD_DOCUMENT_ROOT_PATH=\"$TRASH_DIRECTORY\"\n \n+run_backend() {\n+        echo \"$3\"| \\\n+        QUERY_STRING=\"${2#*\\?}\" \\\n+\tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n+\tPATH_INFO=\"${2%%\\?*}\" \\\n+\tgit http-backend >act.out 2>act.err\n+}\n+\n GET() {\n-    return 0\n+    REQUEST_METHOD=\"GET\" \\\n+    run_backend 0 \"/repo.git/$1\" &&\n+    grep \"Status\" act.out >act\n+    if [ $? -eq 1 ];\n+    then\n+\tprintf \"Status: 200 OK\\r\\n\" > act\n+    fi\n+    printf \"Status: $2\\r\\n\" > exp &&\n+    test_cmp exp act\n }\n \n POST() {\n-    return 0\n+    REQUEST_METHOD=\"POST\" \\\n+    CONTENT_TYPE=\"application/x-$1-request\" \\\n+    run_backend 0 \"/repo.git/$1\" \"$2\" &&\n+    grep \"Status\" act.out >act\n+    if [ $? -eq 1 ];\n+    then\n+\tprintf \"Status: 200 OK\\r\\n\" > act\n+    fi\n+    printf \"Status: $3\\r\\n\" > exp &&\n+    test_cmp exp act\n }\n \n-logdiv() {\n+log_div() {\n     return 0\n }\n \n . \"$TEST_DIRECTORY\"/t556x_common\n \n-run_backend() {\n-\tREQUEST_METHOD=GET \\\n-\tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n-\tPATH_INFO=\"$2\" \\\n-\tgit http-backend >act.out 2>act.err\n-}\n-\n-path_info() {\n-\tif test $1 = 0; then\n-\t\trun_backend \"$2\"\n-\telse\n-\t\ttest_must_fail run_backend \"$2\" &&\n-\t\techo \"fatal: '$2': aliased\" >exp.err &&\n-\t\ttest_cmp exp.err act.err\n-\tfi\n-}\n-\n test_expect_success 'http-backend blocks bad PATH_INFO' '\n \tconfig http.getanyfile true &&\n \n+\tREQUEST_METHOD=\"GET\" &&\n \trun_backend 0 /repo.git/HEAD &&\n \n \trun_backend 1 /repo.git/../HEAD &&\ndiff --git a/t/t556x_common b/t/t556x_common\nindex 1b4921c..be024e5 100755\n--- a/t/t556x_common\n+++ b/t/t556x_common\n@@ -50,6 +50,7 @@ get_static_files() {\n }\n \n SMART=smart\n+export GIT_HTTP_EXPORT_ALL=1\n test_expect_success 'direct refs/heads/master not found' '\n \tlog_div \"refs/heads/master\"\n \tGET refs/heads/master \"404 Not Found\"\n@@ -59,6 +60,7 @@ test_expect_success 'static file is ok' '\n \tget_static_files \"200 OK\"\n '\n SMART=smart_noexport\n+unset GIT_HTTP_EXPORT_ALL\n test_expect_success 'no export by default' '\n \tlog_div \"no git-daemon-export-ok\"\n \tget_static_files \"404 Not Found\"\n@@ -71,6 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' '\n         get_static_files \"200 OK\"\n '\n SMART=smart\n+export GIT_HTTP_EXPORT_ALL=1\n test_expect_success 'static file if http.getanyfile true is ok' '\n \tlog_div \"getanyfile true\"\n \tconfig http.getanyfile true &&\n-- \n1.6.6\n"},{"id":"130657","messageId":"7viqbmo173.fsf@alter.siamese.dyndns.org","threadId":"22042","inReplyTo":"905315640912301009x491f957al839f66de7aba56ed@mail.gmail.com","subject":"Re: [PATCH RFC 1/2] Smart-http tests: Break test t5560-http-backend into pieces","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-01T05:15:28Z","receivedAt":"2010-01-01T05:15:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tarmigan <tarmigan+git@gmail.com> writes:\n\n> One reason it's labeled RFC is that I'm not very confident in my\n> ability to write portable shell script.  It works for me with bash,\n> but I'm not completely confident that is would work on ksh or dash.\n> So it would be nice if you could specifically take a look at the new\n> POST() and GET() and see if you notice anything obviously wrong there.\n\nLooked Ok to me from a cursory reading, even though I wonder what the\nfirst argument to run_backend function is good for...\n"},{"id":"130701","messageId":"905315641001021244o522ac092g7fdaaab83a2609e2@mail.gmail.com","threadId":"22042","inReplyTo":"7viqbmo173.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH RFC 1/2] Smart-http tests: Break test t5560-http-backend into pieces","fromName":"Tarmigan","fromEmail":"tarmigan+git@gmail.com","sentAt":"2010-01-02T20:44:35Z","receivedAt":"2010-01-02T20:44:35Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"On Thu, Dec 31, 2009 at 9:15 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Tarmigan <tarmigan+git@gmail.com> writes:\n>\n>> One reason it's labeled RFC is that I'm not very confident in my\n>> ability to write portable shell script.  It works for me with bash,\n>> but I'm not completely confident that is would work on ksh or dash.\n>> So it would be nice if you could specifically take a look at the new\n>> POST() and GET() and see if you notice anything obviously wrong there.\n>\n> Looked Ok to me from a cursory reading, even though I wonder what the\n> first argument to run_backend function is good for...\n\nThanks for looking.  I used the run_backend that was introduced in\n34b6cb8bb, but looking more closely, it seems that the \"http-backend\nblocks bad PATH_INFO\" test wasn't actually checking anything.  It\nseems the path_info function was intended to be used, but never\nactually was.  I'm embarrassed to say that I was so focused on \"no\nchanges to existing tests\" that I wasn't thinking about the bigger\npicture.\n\nI have made a patch to address this, and have made it the first in the\nseries.  I would like to have Shawn's ack on at least that first\npatch, as I was trying to guess at his original intention with that\ntest.\n\nThanks,\nTarmigan\n"},{"id":"130702","messageId":"1262465119-96115-1-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":"905315641001021244o522ac092g7fdaaab83a2609e2@mail.gmail.com","subject":"[PATCH v3 RFC 1/3] Smart-http tests: Improve coverage in test t5560","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2010-01-02T20:45:17Z","receivedAt":"2010-01-02T20:45:17Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"Commit 34b6cb8bb (\"http-backend: Protect GIT_PROJECT_ROOT from /../\nrequests\") added the path_info helper function to test t5560 but did\nnot use it.  We should use it as it provides another level of error\nchecking.\n\nThe /etc/.../passwd case is one that is not special (and the test\nfails for reasons other than being aliased), so we remove that test\ncase.\n\nAlso rename the function from 'path_info' to 'expect_aliased'.\n\ncc: Shawn O. Pearce <spearce@spearce.org>\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n\n---\nOne thing to note is that\n\texpect_aliased 0 /repo.git/HEAD\ntest still does not actually test any results back from http-backend,\nbut that's also how it was before as well.\n---\n t/t5560-http-backend.sh |   21 ++++++++++-----------\n 1 files changed, 10 insertions(+), 11 deletions(-)\n\ndiff --git a/t/t5560-http-backend.sh b/t/t5560-http-backend.sh\nindex 04a9896..0e4dc4b 100755\n--- a/t/t5560-http-backend.sh\n+++ b/t/t5560-http-backend.sh\n@@ -162,15 +162,15 @@ test_expect_success 'http.receivepack false' '\n run_backend() {\n \tREQUEST_METHOD=GET \\\n \tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n-\tPATH_INFO=\"$2\" \\\n+\tPATH_INFO=\"$1\" \\\n \tgit http-backend >act.out 2>act.err\n }\n \n-path_info() {\n+expect_aliased() {\n \tif test $1 = 0; then\n \t\trun_backend \"$2\"\n \telse\n-\t\ttest_must_fail run_backend \"$2\" &&\n+\t\trun_backend \"$2\" &&\n \t\techo \"fatal: '$2': aliased\" >exp.err &&\n \t\ttest_cmp exp.err act.err\n \tfi\n@@ -179,15 +179,14 @@ path_info() {\n test_expect_success 'http-backend blocks bad PATH_INFO' '\n \tconfig http.getanyfile true &&\n \n-\trun_backend 0 /repo.git/HEAD &&\n+\texpect_aliased 0 /repo.git/HEAD &&\n \n-\trun_backend 1 /repo.git/../HEAD &&\n-\trun_backend 1 /../etc/passwd &&\n-\trun_backend 1 ../etc/passwd &&\n-\trun_backend 1 /etc//passwd &&\n-\trun_backend 1 /etc/./passwd &&\n-\trun_backend 1 /etc/.../passwd &&\n-\trun_backend 1 //domain/data.txt\n+\texpect_aliased 1 /repo.git/../HEAD &&\n+\texpect_aliased 1 /../etc/passwd &&\n+\texpect_aliased 1 ../etc/passwd &&\n+\texpect_aliased 1 /etc//passwd &&\n+\texpect_aliased 1 /etc/./passwd &&\n+\texpect_aliased 1 //domain/data.txt\n '\n \n cat >exp <<EOF\n-- \n1.6.6\n"},{"id":"130703","messageId":"1262465119-96115-2-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":"905315641001021244o522ac092g7fdaaab83a2609e2@mail.gmail.com","subject":"[PATCH v3 2/3] Smart-http tests: Break test t5560-http-backend into pieces","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2010-01-02T20:45:18Z","receivedAt":"2010-01-02T20:45:18Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"This should introduce no functional change in the tests or the amount\nof test coverage.\n\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n---\n t/t5560-http-backend.sh          |  147 +-------------------------------------\n t/t5561-http-backend-noserver.sh |   52 +++++++++++++\n t/t556x_common                   |  119 ++++++++++++++++++++++++++++++\n 3 files changed, 172 insertions(+), 146 deletions(-)\n create mode 100755 t/t5561-http-backend-noserver.sh\n create mode 100755 t/t556x_common\n\ndiff --git a/t/t5560-http-backend.sh b/t/t5560-http-backend.sh\nindex 0e4dc4b..dd844d3 100755\n--- a/t/t5560-http-backend.sh\n+++ b/t/t5560-http-backend.sh\n@@ -12,16 +12,6 @@ LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5560'}\n . \"$TEST_DIRECTORY\"/lib-httpd.sh\n start_httpd\n \n-find_file() {\n-\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\tfind $1 -type f |\n-\tsed -e 1q\n-}\n-\n-config() {\n-\tgit --git-dir=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" config $1 $2\n-}\n-\n GET() {\n \tcurl --include \"$HTTPD_URL/$SMART/repo.git/$1\" >out 2>/dev/null &&\n \ttr '\\015' Q <out |\n@@ -52,142 +42,7 @@ log_div() {\n \techo \"###\" >>\"$HTTPD_ROOT_PATH\"/access.log\n }\n \n-test_expect_success 'setup repository' '\n-\techo content >file &&\n-\tgit add file &&\n-\tgit commit -m one &&\n-\n-\tmkdir \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t git --bare init &&\n-\t : >objects/info/alternates &&\n-\t : >objects/info/http-alternates\n-\t) &&\n-\tgit remote add public \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\tgit push public master:master &&\n-\n-\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t git repack -a -d\n-\t) &&\n-\n-\techo other >file &&\n-\tgit add file &&\n-\tgit commit -m two &&\n-\tgit push public master:master &&\n-\n-\tLOOSE_URL=$(find_file objects/??) &&\n-\tPACK_URL=$(find_file objects/pack/*.pack) &&\n-\tIDX_URL=$(find_file objects/pack/*.idx)\n-'\n-\n-get_static_files() {\n-\tGET HEAD \"$1\" &&\n-\tGET info/refs \"$1\" &&\n-\tGET objects/info/packs \"$1\" &&\n-\tGET objects/info/alternates \"$1\" &&\n-\tGET objects/info/http-alternates \"$1\" &&\n-\tGET $LOOSE_URL \"$1\" &&\n-\tGET $PACK_URL \"$1\" &&\n-\tGET $IDX_URL \"$1\"\n-}\n-\n-SMART=smart\n-test_expect_success 'direct refs/heads/master not found' '\n-\tlog_div \"refs/heads/master\"\n-\tGET refs/heads/master \"404 Not Found\"\n-'\n-test_expect_success 'static file is ok' '\n-\tlog_div \"getanyfile default\"\n-\tget_static_files \"200 OK\"\n-'\n-SMART=smart_noexport\n-test_expect_success 'no export by default' '\n-\tlog_div \"no git-daemon-export-ok\"\n-\tget_static_files \"404 Not Found\"\n-'\n-test_expect_success 'export if git-daemon-export-ok' '\n-\tlog_div \"git-daemon-export-ok\"\n-        (cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t touch git-daemon-export-ok\n-\t) &&\n-        get_static_files \"200 OK\"\n-'\n-SMART=smart\n-test_expect_success 'static file if http.getanyfile true is ok' '\n-\tlog_div \"getanyfile true\"\n-\tconfig http.getanyfile true &&\n-\tget_static_files \"200 OK\"\n-'\n-test_expect_success 'static file if http.getanyfile false fails' '\n-\tlog_div \"getanyfile false\"\n-\tconfig http.getanyfile false &&\n-\tget_static_files \"403 Forbidden\"\n-'\n-\n-test_expect_success 'http.uploadpack default enabled' '\n-\tlog_div \"uploadpack default\"\n-\tGET info/refs?service=git-upload-pack \"200 OK\"  &&\n-\tPOST git-upload-pack 0000 \"200 OK\"\n-'\n-test_expect_success 'http.uploadpack true' '\n-\tlog_div \"uploadpack true\"\n-\tconfig http.uploadpack true &&\n-\tGET info/refs?service=git-upload-pack \"200 OK\" &&\n-\tPOST git-upload-pack 0000 \"200 OK\"\n-'\n-test_expect_success 'http.uploadpack false' '\n-\tlog_div \"uploadpack false\"\n-\tconfig http.uploadpack false &&\n-\tGET info/refs?service=git-upload-pack \"403 Forbidden\" &&\n-\tPOST git-upload-pack 0000 \"403 Forbidden\"\n-'\n-\n-test_expect_success 'http.receivepack default disabled' '\n-\tlog_div \"receivepack default\"\n-\tGET info/refs?service=git-receive-pack \"403 Forbidden\"  &&\n-\tPOST git-receive-pack 0000 \"403 Forbidden\"\n-'\n-test_expect_success 'http.receivepack true' '\n-\tlog_div \"receivepack true\"\n-\tconfig http.receivepack true &&\n-\tGET info/refs?service=git-receive-pack \"200 OK\" &&\n-\tPOST git-receive-pack 0000 \"200 OK\"\n-'\n-test_expect_success 'http.receivepack false' '\n-\tlog_div \"receivepack false\"\n-\tconfig http.receivepack false &&\n-\tGET info/refs?service=git-receive-pack \"403 Forbidden\" &&\n-\tPOST git-receive-pack 0000 \"403 Forbidden\"\n-'\n-run_backend() {\n-\tREQUEST_METHOD=GET \\\n-\tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n-\tPATH_INFO=\"$1\" \\\n-\tgit http-backend >act.out 2>act.err\n-}\n-\n-expect_aliased() {\n-\tif test $1 = 0; then\n-\t\trun_backend \"$2\"\n-\telse\n-\t\trun_backend \"$2\" &&\n-\t\techo \"fatal: '$2': aliased\" >exp.err &&\n-\t\ttest_cmp exp.err act.err\n-\tfi\n-}\n-\n-test_expect_success 'http-backend blocks bad PATH_INFO' '\n-\tconfig http.getanyfile true &&\n-\n-\texpect_aliased 0 /repo.git/HEAD &&\n-\n-\texpect_aliased 1 /repo.git/../HEAD &&\n-\texpect_aliased 1 /../etc/passwd &&\n-\texpect_aliased 1 ../etc/passwd &&\n-\texpect_aliased 1 /etc//passwd &&\n-\texpect_aliased 1 /etc/./passwd &&\n-\texpect_aliased 1 //domain/data.txt\n-'\n+. \"$TEST_DIRECTORY\"/t556x_common\n \n cat >exp <<EOF\n \ndiff --git a/t/t5561-http-backend-noserver.sh b/t/t5561-http-backend-noserver.sh\nnew file mode 100755\nindex 0000000..a9ba2d9\n--- /dev/null\n+++ b/t/t5561-http-backend-noserver.sh\n@@ -0,0 +1,52 @@\n+#!/bin/sh\n+\n+test_description='test git-http-backend-noserver'\n+. ./test-lib.sh\n+\n+HTTPD_DOCUMENT_ROOT_PATH=\"$TRASH_DIRECTORY\"\n+\n+run_backend() {\n+\tREQUEST_METHOD=GET \\\n+\tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n+\tPATH_INFO=\"$1\" \\\n+\tgit http-backend >act.out 2>act.err\n+}\n+\n+GET() {\n+\treturn 0\n+}\n+\n+POST() {\n+\treturn 0\n+}\n+\n+log_div() {\n+\treturn 0\n+}\n+\n+. \"$TEST_DIRECTORY\"/t556x_common\n+\n+expect_aliased() {\n+\tif test $1 = 0; then\n+\t\trun_backend \"$2\"\n+\telse\n+\t\trun_backend \"$2\" &&\n+\t\techo \"fatal: '$2': aliased\" >exp.err &&\n+\t\ttest_cmp exp.err act.err\n+\tfi\n+}\n+\n+test_expect_success 'http-backend blocks bad PATH_INFO' '\n+\tconfig http.getanyfile true &&\n+\n+\texpect_aliased 0 /repo.git/HEAD &&\n+\n+\texpect_aliased 1 /repo.git/../HEAD &&\n+\texpect_aliased 1 /../etc/passwd &&\n+\texpect_aliased 1 ../etc/passwd &&\n+\texpect_aliased 1 /etc//passwd &&\n+\texpect_aliased 1 /etc/./passwd &&\n+\texpect_aliased 1 //domain/data.txt\n+'\n+\n+test_done\ndiff --git a/t/t556x_common b/t/t556x_common\nnew file mode 100755\nindex 0000000..1b4921c\n--- /dev/null\n+++ b/t/t556x_common\n@@ -0,0 +1,119 @@\n+#!/bin/sh\n+\n+find_file() {\n+\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\tfind $1 -type f |\n+\tsed -e 1q\n+}\n+\n+config() {\n+\tgit --git-dir=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" config $1 $2\n+}\n+\n+test_expect_success 'setup repository' '\n+\techo content >file &&\n+\tgit add file &&\n+\tgit commit -m one &&\n+\n+\tmkdir \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t git --bare init &&\n+\t : >objects/info/alternates &&\n+\t : >objects/info/http-alternates\n+\t) &&\n+\tgit remote add public \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\tgit push public master:master &&\n+\n+\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t git repack -a -d\n+\t) &&\n+\n+\techo other >file &&\n+\tgit add file &&\n+\tgit commit -m two &&\n+\tgit push public master:master &&\n+\n+\tLOOSE_URL=$(find_file objects/??) &&\n+\tPACK_URL=$(find_file objects/pack/*.pack) &&\n+\tIDX_URL=$(find_file objects/pack/*.idx)\n+'\n+\n+get_static_files() {\n+\tGET HEAD \"$1\" &&\n+\tGET info/refs \"$1\" &&\n+\tGET objects/info/packs \"$1\" &&\n+\tGET objects/info/alternates \"$1\" &&\n+\tGET objects/info/http-alternates \"$1\" &&\n+\tGET $LOOSE_URL \"$1\" &&\n+\tGET $PACK_URL \"$1\" &&\n+\tGET $IDX_URL \"$1\"\n+}\n+\n+SMART=smart\n+test_expect_success 'direct refs/heads/master not found' '\n+\tlog_div \"refs/heads/master\"\n+\tGET refs/heads/master \"404 Not Found\"\n+'\n+test_expect_success 'static file is ok' '\n+\tlog_div \"getanyfile default\"\n+\tget_static_files \"200 OK\"\n+'\n+SMART=smart_noexport\n+test_expect_success 'no export by default' '\n+\tlog_div \"no git-daemon-export-ok\"\n+\tget_static_files \"404 Not Found\"\n+'\n+test_expect_success 'export if git-daemon-export-ok' '\n+\tlog_div \"git-daemon-export-ok\"\n+        (cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t touch git-daemon-export-ok\n+\t) &&\n+        get_static_files \"200 OK\"\n+'\n+SMART=smart\n+test_expect_success 'static file if http.getanyfile true is ok' '\n+\tlog_div \"getanyfile true\"\n+\tconfig http.getanyfile true &&\n+\tget_static_files \"200 OK\"\n+'\n+test_expect_success 'static file if http.getanyfile false fails' '\n+\tlog_div \"getanyfile false\"\n+\tconfig http.getanyfile false &&\n+\tget_static_files \"403 Forbidden\"\n+'\n+\n+test_expect_success 'http.uploadpack default enabled' '\n+\tlog_div \"uploadpack default\"\n+\tGET info/refs?service=git-upload-pack \"200 OK\"  &&\n+\tPOST git-upload-pack 0000 \"200 OK\"\n+'\n+test_expect_success 'http.uploadpack true' '\n+\tlog_div \"uploadpack true\"\n+\tconfig http.uploadpack true &&\n+\tGET info/refs?service=git-upload-pack \"200 OK\" &&\n+\tPOST git-upload-pack 0000 \"200 OK\"\n+'\n+test_expect_success 'http.uploadpack false' '\n+\tlog_div \"uploadpack false\"\n+\tconfig http.uploadpack false &&\n+\tGET info/refs?service=git-upload-pack \"403 Forbidden\" &&\n+\tPOST git-upload-pack 0000 \"403 Forbidden\"\n+'\n+\n+test_expect_success 'http.receivepack default disabled' '\n+\tlog_div \"receivepack default\"\n+\tGET info/refs?service=git-receive-pack \"403 Forbidden\"  &&\n+\tPOST git-receive-pack 0000 \"403 Forbidden\"\n+'\n+test_expect_success 'http.receivepack true' '\n+\tlog_div \"receivepack true\"\n+\tconfig http.receivepack true &&\n+\tGET info/refs?service=git-receive-pack \"200 OK\" &&\n+\tPOST git-receive-pack 0000 \"200 OK\"\n+'\n+test_expect_success 'http.receivepack false' '\n+\tlog_div \"receivepack false\"\n+\tconfig http.receivepack false &&\n+\tGET info/refs?service=git-receive-pack \"403 Forbidden\" &&\n+\tPOST git-receive-pack 0000 \"403 Forbidden\"\n+'\n-- \n1.6.6\n"},{"id":"130704","messageId":"1262465119-96115-3-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":"905315641001021244o522ac092g7fdaaab83a2609e2@mail.gmail.com","subject":"[PATCH v3 3/3] Smart-http tests: Test http-backend without curl or a webserver","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2010-01-02T20:45:19Z","receivedAt":"2010-01-02T20:45:19Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"This reuses many of the tests from t5560 but runs those tests without\ncurl or a webserver.  This will hopefully increase the testing\ncoverage for http-backend because it does not require users to set\nGIT_TEST_HTTPD.\n\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n---\n t/t5561-http-backend-noserver.sh |   30 ++++++++++++++++++++++++------\n t/t556x_common                   |    3 +++\n 2 files changed, 27 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t5561-http-backend-noserver.sh b/t/t5561-http-backend-noserver.sh\nindex a9ba2d9..9013824 100755\n--- a/t/t5561-http-backend-noserver.sh\n+++ b/t/t5561-http-backend-noserver.sh\n@@ -6,18 +6,36 @@ test_description='test git-http-backend-noserver'\n HTTPD_DOCUMENT_ROOT_PATH=\"$TRASH_DIRECTORY\"\n \n run_backend() {\n-\tREQUEST_METHOD=GET \\\n+\techo \"$2\"| \\\n+\tQUERY_STRING=\"${1#*\\?}\" \\\n \tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n-\tPATH_INFO=\"$1\" \\\n+\tPATH_INFO=\"${1%%\\?*}\" \\\n \tgit http-backend >act.out 2>act.err\n }\n \n GET() {\n-\treturn 0\n+\tREQUEST_METHOD=\"GET\" \\\n+\trun_backend \"/repo.git/$1\" &&\n+\tgrep \"Status\" act.out >act\n+\tif [ $? -eq 1 ];\n+\tthen\n+\t\tprintf \"Status: 200 OK\\r\\n\" > act\n+\tfi\n+\tprintf \"Status: $2\\r\\n\" > exp &&\n+\ttest_cmp exp act\n }\n \n POST() {\n-\treturn 0\n+\tREQUEST_METHOD=\"POST\" \\\n+\tCONTENT_TYPE=\"application/x-$1-request\" \\\n+\trun_backend \"/repo.git/$1\" \"$2\" &&\n+\tgrep \"Status\" act.out >act\n+\tif [ $? -eq 1 ];\n+\tthen\n+\t\tprintf \"Status: 200 OK\\r\\n\" > act\n+\tfi\n+\tprintf \"Status: $3\\r\\n\" > exp &&\n+\ttest_cmp exp act\n }\n \n log_div() {\n@@ -28,9 +46,9 @@ log_div() {\n \n expect_aliased() {\n \tif test $1 = 0; then\n-\t\trun_backend \"$2\"\n+\t\tREQUEST_METHOD=GET run_backend \"$2\"\n \telse\n-\t\trun_backend \"$2\" &&\n+\t\tREQUEST_METHOD=GET run_backend \"$2\" &&\n \t\techo \"fatal: '$2': aliased\" >exp.err &&\n \t\ttest_cmp exp.err act.err\n \tfi\ndiff --git a/t/t556x_common b/t/t556x_common\nindex 1b4921c..be024e5 100755\n--- a/t/t556x_common\n+++ b/t/t556x_common\n@@ -50,6 +50,7 @@ get_static_files() {\n }\n \n SMART=smart\n+export GIT_HTTP_EXPORT_ALL=1\n test_expect_success 'direct refs/heads/master not found' '\n \tlog_div \"refs/heads/master\"\n \tGET refs/heads/master \"404 Not Found\"\n@@ -59,6 +60,7 @@ test_expect_success 'static file is ok' '\n \tget_static_files \"200 OK\"\n '\n SMART=smart_noexport\n+unset GIT_HTTP_EXPORT_ALL\n test_expect_success 'no export by default' '\n \tlog_div \"no git-daemon-export-ok\"\n \tget_static_files \"404 Not Found\"\n@@ -71,6 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' '\n         get_static_files \"200 OK\"\n '\n SMART=smart\n+export GIT_HTTP_EXPORT_ALL=1\n test_expect_success 'static file if http.getanyfile true is ok' '\n \tlog_div \"getanyfile true\"\n \tconfig http.getanyfile true &&\n-- \n1.6.6\n"},{"id":"130706","messageId":"20100102205414.GL6914@spearce.org","threadId":"22042","inReplyTo":"1262465119-96115-1-git-send-email-tarmigan+git@gmail.com","subject":"Re: [PATCH v3 RFC 1/3] Smart-http tests: Improve coverage in test t5560","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2010-01-02T20:54:14Z","receivedAt":"2010-01-02T20:54:14Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Tarmigan Casebolt <tarmigan+git@gmail.com> wrote:\n> Commit 34b6cb8bb (\"http-backend: Protect GIT_PROJECT_ROOT from /../\n> requests\") added the path_info helper function to test t5560 but did\n> not use it.  We should use it as it provides another level of error\n> checking.\n> \n> The /etc/.../passwd case is one that is not special (and the test\n> fails for reasons other than being aliased), so we remove that test\n> case.\n> \n> Also rename the function from 'path_info' to 'expect_aliased'.\n> \n> cc: Shawn O. Pearce <spearce@spearce.org>\n\nAcked-by: Shawn O. Pearce <spearce@spearce.org>\n\n-- \nShawn.\n"},{"id":"130707","messageId":"20100102205928.GM6914@spearce.org","threadId":"22042","inReplyTo":"1262465119-96115-2-git-send-email-tarmigan+git@gmail.com","subject":"Re: [PATCH v3 2/3] Smart-http tests: Break test t5560-http-backend into pieces","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2010-01-02T20:59:28Z","receivedAt":"2010-01-02T20:59:28Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Tarmigan Casebolt <tarmigan+git@gmail.com> wrote:\n> This should introduce no functional change in the tests or the amount\n> of test coverage.\n> \n> Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n> ---\n>  t/t5560-http-backend.sh          |  147 +-------------------------------------\n>  t/t5561-http-backend-noserver.sh |   52 +++++++++++++\n\nThese should be reversed.  We'd want to find out the backend doesn't\nwork by itself before we see it fail under Apache.\n\nOtherwise, Acked-by: Shawn O. Pearce <spearce@spearce.org>\n\n-- \nShawn.\n"},{"id":"130708","messageId":"20100102210318.GN6914@spearce.org","threadId":"22042","inReplyTo":"1262465119-96115-3-git-send-email-tarmigan+git@gmail.com","subject":"Re: [PATCH v3 3/3] Smart-http tests: Test http-backend without curl or a webserver","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2010-01-02T21:03:18Z","receivedAt":"2010-01-02T21:03:18Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Tarmigan Casebolt <tarmigan+git@gmail.com> wrote:\n>  GET() {\n> -\treturn 0\n> +\tREQUEST_METHOD=\"GET\" \\\n> +\trun_backend \"/repo.git/$1\" &&\n> +\tgrep \"Status\" act.out >act\n> +\tif [ $? -eq 1 ];\n\nI think this should be spelled as:\n\n\tif ! grep \"Status\" act.out >act; then\n\t\tprintf \"Status: 200 OK\\r\\n\" > act\n\tfi\n\n-- \nShawn.\n"},{"id":"130710","messageId":"905315641001021337v238515c8s34d820236dac698d@mail.gmail.com","threadId":"22042","inReplyTo":"20100102210318.GN6914@spearce.org","subject":"Re: [PATCH v3 3/3] Smart-http tests: Test http-backend without curl or a webserver","fromName":"Tarmigan","fromEmail":"tarmigan+git@gmail.com","sentAt":"2010-01-02T21:37:38Z","receivedAt":"2010-01-02T21:37:38Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"On Sat, Jan 2, 2010 at 1:03 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Tarmigan Casebolt <tarmigan+git@gmail.com> wrote:\n>>  GET() {\n>> -     return 0\n>> +     REQUEST_METHOD=\"GET\" \\\n>> +     run_backend \"/repo.git/$1\" &&\n>> +     grep \"Status\" act.out >act\n>> +     if [ $? -eq 1 ];\n>\n> I think this should be spelled as:\n>\n>        if ! grep \"Status\" act.out >act; then\n>                printf \"Status: 200 OK\\r\\n\" > act\n>        fi\n\nOK.  I had figured the \"1\" would mean \"no matches not found\"  rather\nthan some other error like \"file does not exist\".  Not sure how\nportable that error value convention is for greps though, so I've\nchanged it as you suggested.\n\nThanks,\nTarmigan\n"},{"id":"130711","messageId":"1262468287-8629-1-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":"20100102205928.GM6914@spearce.org","subject":"[PATCH v4 1/3] Smart-http tests: Improve coverage in test t5560","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2010-01-02T21:38:05Z","receivedAt":"2010-01-02T21:38:05Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"Commit 34b6cb8bb (\"http-backend: Protect GIT_PROJECT_ROOT from /../\nrequests\") added the path_info helper function to test t5560 but did\nnot use it.  We should use it as it provides another level of error\nchecking.\n\nThe /etc/.../passwd case is one that is not special (and the test\nfails for reasons other than being aliased), so we remove that test\ncase.\n\nAlso rename the function from 'path_info' to 'expect_aliased'.\n\nAcked-by: Shawn O. Pearce <spearce@spearce.org>\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n\n---\nOne thing to note is that\n\texpect_aliased 0 /repo.git/HEAD\ntest still does not actually test any results back from http-backend,\nbut that's also how it was before as well.\n---\n t/t5560-http-backend.sh |   21 ++++++++++-----------\n 1 files changed, 10 insertions(+), 11 deletions(-)\n\ndiff --git a/t/t5560-http-backend.sh b/t/t5560-http-backend.sh\nindex 04a9896..0e4dc4b 100755\n--- a/t/t5560-http-backend.sh\n+++ b/t/t5560-http-backend.sh\n@@ -162,15 +162,15 @@ test_expect_success 'http.receivepack false' '\n run_backend() {\n \tREQUEST_METHOD=GET \\\n \tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n-\tPATH_INFO=\"$2\" \\\n+\tPATH_INFO=\"$1\" \\\n \tgit http-backend >act.out 2>act.err\n }\n \n-path_info() {\n+expect_aliased() {\n \tif test $1 = 0; then\n \t\trun_backend \"$2\"\n \telse\n-\t\ttest_must_fail run_backend \"$2\" &&\n+\t\trun_backend \"$2\" &&\n \t\techo \"fatal: '$2': aliased\" >exp.err &&\n \t\ttest_cmp exp.err act.err\n \tfi\n@@ -179,15 +179,14 @@ path_info() {\n test_expect_success 'http-backend blocks bad PATH_INFO' '\n \tconfig http.getanyfile true &&\n \n-\trun_backend 0 /repo.git/HEAD &&\n+\texpect_aliased 0 /repo.git/HEAD &&\n \n-\trun_backend 1 /repo.git/../HEAD &&\n-\trun_backend 1 /../etc/passwd &&\n-\trun_backend 1 ../etc/passwd &&\n-\trun_backend 1 /etc//passwd &&\n-\trun_backend 1 /etc/./passwd &&\n-\trun_backend 1 /etc/.../passwd &&\n-\trun_backend 1 //domain/data.txt\n+\texpect_aliased 1 /repo.git/../HEAD &&\n+\texpect_aliased 1 /../etc/passwd &&\n+\texpect_aliased 1 ../etc/passwd &&\n+\texpect_aliased 1 /etc//passwd &&\n+\texpect_aliased 1 /etc/./passwd &&\n+\texpect_aliased 1 //domain/data.txt\n '\n \n cat >exp <<EOF\n-- \n1.6.6.236.gc56f3\n"},{"id":"130713","messageId":"1262468287-8629-2-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":"20100102205928.GM6914@spearce.org","subject":"[PATCH v4 2/3] Smart-http tests: Break test t5560-http-backend into pieces","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2010-01-02T21:38:06Z","receivedAt":"2010-01-02T21:38:06Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"This should introduce no functional change in the tests or the amount\nof test coverage.\n\nAcked-by: Shawn O. Pearce <spearce@spearce.org>\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n---\n t/t5560-http-backend-noserver.sh |   52 +++++++\n t/t5560-http-backend.sh          |  294 --------------------------------------\n t/t5561-http-backend.sh          |  149 +++++++++++++++++++\n t/t556x_common                   |  119 +++++++++++++++\n 4 files changed, 320 insertions(+), 294 deletions(-)\n create mode 100755 t/t5560-http-backend-noserver.sh\n delete mode 100755 t/t5560-http-backend.sh\n create mode 100755 t/t5561-http-backend.sh\n create mode 100755 t/t556x_common\n\ndiff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh\nnew file mode 100755\nindex 0000000..a9ba2d9\n--- /dev/null\n+++ b/t/t5560-http-backend-noserver.sh\n@@ -0,0 +1,52 @@\n+#!/bin/sh\n+\n+test_description='test git-http-backend-noserver'\n+. ./test-lib.sh\n+\n+HTTPD_DOCUMENT_ROOT_PATH=\"$TRASH_DIRECTORY\"\n+\n+run_backend() {\n+\tREQUEST_METHOD=GET \\\n+\tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n+\tPATH_INFO=\"$1\" \\\n+\tgit http-backend >act.out 2>act.err\n+}\n+\n+GET() {\n+\treturn 0\n+}\n+\n+POST() {\n+\treturn 0\n+}\n+\n+log_div() {\n+\treturn 0\n+}\n+\n+. \"$TEST_DIRECTORY\"/t556x_common\n+\n+expect_aliased() {\n+\tif test $1 = 0; then\n+\t\trun_backend \"$2\"\n+\telse\n+\t\trun_backend \"$2\" &&\n+\t\techo \"fatal: '$2': aliased\" >exp.err &&\n+\t\ttest_cmp exp.err act.err\n+\tfi\n+}\n+\n+test_expect_success 'http-backend blocks bad PATH_INFO' '\n+\tconfig http.getanyfile true &&\n+\n+\texpect_aliased 0 /repo.git/HEAD &&\n+\n+\texpect_aliased 1 /repo.git/../HEAD &&\n+\texpect_aliased 1 /../etc/passwd &&\n+\texpect_aliased 1 ../etc/passwd &&\n+\texpect_aliased 1 /etc//passwd &&\n+\texpect_aliased 1 /etc/./passwd &&\n+\texpect_aliased 1 //domain/data.txt\n+'\n+\n+test_done\ndiff --git a/t/t5560-http-backend.sh b/t/t5560-http-backend.sh\ndeleted file mode 100755\nindex 0e4dc4b..0000000\n--- a/t/t5560-http-backend.sh\n+++ /dev/null\n@@ -1,294 +0,0 @@\n-#!/bin/sh\n-\n-test_description='test git-http-backend'\n-. ./test-lib.sh\n-\n-if test -n \"$NO_CURL\"; then\n-\tsay 'skipping test, git built without http support'\n-\ttest_done\n-fi\n-\n-LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5560'}\n-. \"$TEST_DIRECTORY\"/lib-httpd.sh\n-start_httpd\n-\n-find_file() {\n-\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\tfind $1 -type f |\n-\tsed -e 1q\n-}\n-\n-config() {\n-\tgit --git-dir=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" config $1 $2\n-}\n-\n-GET() {\n-\tcurl --include \"$HTTPD_URL/$SMART/repo.git/$1\" >out 2>/dev/null &&\n-\ttr '\\015' Q <out |\n-\tsed '\n-\t\ts/Q$//\n-\t\t1q\n-\t' >act &&\n-\techo \"HTTP/1.1 $2\" >exp &&\n-\ttest_cmp exp act\n-}\n-\n-POST() {\n-\tcurl --include --data \"$2\" \\\n-\t--header \"Content-Type: application/x-$1-request\" \\\n-\t\"$HTTPD_URL/smart/repo.git/$1\" >out 2>/dev/null &&\n-\ttr '\\015' Q <out |\n-\tsed '\n-\t\ts/Q$//\n-\t\t1q\n-\t' >act &&\n-\techo \"HTTP/1.1 $3\" >exp &&\n-\ttest_cmp exp act\n-}\n-\n-log_div() {\n-\techo >>\"$HTTPD_ROOT_PATH\"/access.log\n-\techo \"###  $1\" >>\"$HTTPD_ROOT_PATH\"/access.log\n-\techo \"###\" >>\"$HTTPD_ROOT_PATH\"/access.log\n-}\n-\n-test_expect_success 'setup repository' '\n-\techo content >file &&\n-\tgit add file &&\n-\tgit commit -m one &&\n-\n-\tmkdir \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t git --bare init &&\n-\t : >objects/info/alternates &&\n-\t : >objects/info/http-alternates\n-\t) &&\n-\tgit remote add public \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\tgit push public master:master &&\n-\n-\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t git repack -a -d\n-\t) &&\n-\n-\techo other >file &&\n-\tgit add file &&\n-\tgit commit -m two &&\n-\tgit push public master:master &&\n-\n-\tLOOSE_URL=$(find_file objects/??) &&\n-\tPACK_URL=$(find_file objects/pack/*.pack) &&\n-\tIDX_URL=$(find_file objects/pack/*.idx)\n-'\n-\n-get_static_files() {\n-\tGET HEAD \"$1\" &&\n-\tGET info/refs \"$1\" &&\n-\tGET objects/info/packs \"$1\" &&\n-\tGET objects/info/alternates \"$1\" &&\n-\tGET objects/info/http-alternates \"$1\" &&\n-\tGET $LOOSE_URL \"$1\" &&\n-\tGET $PACK_URL \"$1\" &&\n-\tGET $IDX_URL \"$1\"\n-}\n-\n-SMART=smart\n-test_expect_success 'direct refs/heads/master not found' '\n-\tlog_div \"refs/heads/master\"\n-\tGET refs/heads/master \"404 Not Found\"\n-'\n-test_expect_success 'static file is ok' '\n-\tlog_div \"getanyfile default\"\n-\tget_static_files \"200 OK\"\n-'\n-SMART=smart_noexport\n-test_expect_success 'no export by default' '\n-\tlog_div \"no git-daemon-export-ok\"\n-\tget_static_files \"404 Not Found\"\n-'\n-test_expect_success 'export if git-daemon-export-ok' '\n-\tlog_div \"git-daemon-export-ok\"\n-        (cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n-\t touch git-daemon-export-ok\n-\t) &&\n-        get_static_files \"200 OK\"\n-'\n-SMART=smart\n-test_expect_success 'static file if http.getanyfile true is ok' '\n-\tlog_div \"getanyfile true\"\n-\tconfig http.getanyfile true &&\n-\tget_static_files \"200 OK\"\n-'\n-test_expect_success 'static file if http.getanyfile false fails' '\n-\tlog_div \"getanyfile false\"\n-\tconfig http.getanyfile false &&\n-\tget_static_files \"403 Forbidden\"\n-'\n-\n-test_expect_success 'http.uploadpack default enabled' '\n-\tlog_div \"uploadpack default\"\n-\tGET info/refs?service=git-upload-pack \"200 OK\"  &&\n-\tPOST git-upload-pack 0000 \"200 OK\"\n-'\n-test_expect_success 'http.uploadpack true' '\n-\tlog_div \"uploadpack true\"\n-\tconfig http.uploadpack true &&\n-\tGET info/refs?service=git-upload-pack \"200 OK\" &&\n-\tPOST git-upload-pack 0000 \"200 OK\"\n-'\n-test_expect_success 'http.uploadpack false' '\n-\tlog_div \"uploadpack false\"\n-\tconfig http.uploadpack false &&\n-\tGET info/refs?service=git-upload-pack \"403 Forbidden\" &&\n-\tPOST git-upload-pack 0000 \"403 Forbidden\"\n-'\n-\n-test_expect_success 'http.receivepack default disabled' '\n-\tlog_div \"receivepack default\"\n-\tGET info/refs?service=git-receive-pack \"403 Forbidden\"  &&\n-\tPOST git-receive-pack 0000 \"403 Forbidden\"\n-'\n-test_expect_success 'http.receivepack true' '\n-\tlog_div \"receivepack true\"\n-\tconfig http.receivepack true &&\n-\tGET info/refs?service=git-receive-pack \"200 OK\" &&\n-\tPOST git-receive-pack 0000 \"200 OK\"\n-'\n-test_expect_success 'http.receivepack false' '\n-\tlog_div \"receivepack false\"\n-\tconfig http.receivepack false &&\n-\tGET info/refs?service=git-receive-pack \"403 Forbidden\" &&\n-\tPOST git-receive-pack 0000 \"403 Forbidden\"\n-'\n-run_backend() {\n-\tREQUEST_METHOD=GET \\\n-\tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n-\tPATH_INFO=\"$1\" \\\n-\tgit http-backend >act.out 2>act.err\n-}\n-\n-expect_aliased() {\n-\tif test $1 = 0; then\n-\t\trun_backend \"$2\"\n-\telse\n-\t\trun_backend \"$2\" &&\n-\t\techo \"fatal: '$2': aliased\" >exp.err &&\n-\t\ttest_cmp exp.err act.err\n-\tfi\n-}\n-\n-test_expect_success 'http-backend blocks bad PATH_INFO' '\n-\tconfig http.getanyfile true &&\n-\n-\texpect_aliased 0 /repo.git/HEAD &&\n-\n-\texpect_aliased 1 /repo.git/../HEAD &&\n-\texpect_aliased 1 /../etc/passwd &&\n-\texpect_aliased 1 ../etc/passwd &&\n-\texpect_aliased 1 /etc//passwd &&\n-\texpect_aliased 1 /etc/./passwd &&\n-\texpect_aliased 1 //domain/data.txt\n-'\n-\n-cat >exp <<EOF\n-\n-###  refs/heads/master\n-###\n-GET  /smart/repo.git/refs/heads/master HTTP/1.1 404 -\n-\n-###  getanyfile default\n-###\n-GET  /smart/repo.git/HEAD HTTP/1.1 200\n-GET  /smart/repo.git/info/refs HTTP/1.1 200\n-GET  /smart/repo.git/objects/info/packs HTTP/1.1 200\n-GET  /smart/repo.git/objects/info/alternates HTTP/1.1 200 -\n-GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -\n-GET  /smart/repo.git/$LOOSE_URL HTTP/1.1 200\n-GET  /smart/repo.git/$PACK_URL HTTP/1.1 200\n-GET  /smart/repo.git/$IDX_URL HTTP/1.1 200\n-\n-###  no git-daemon-export-ok\n-###\n-GET  /smart_noexport/repo.git/HEAD HTTP/1.1 404 -\n-GET  /smart_noexport/repo.git/info/refs HTTP/1.1 404 -\n-GET  /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -\n-GET  /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -\n-GET  /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -\n-GET  /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 404 -\n-GET  /smart_noexport/repo.git/$PACK_URL HTTP/1.1 404 -\n-GET  /smart_noexport/repo.git/$IDX_URL HTTP/1.1 404 -\n-\n-###  git-daemon-export-ok\n-###\n-GET  /smart_noexport/repo.git/HEAD HTTP/1.1 200\n-GET  /smart_noexport/repo.git/info/refs HTTP/1.1 200\n-GET  /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200\n-GET  /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -\n-GET  /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -\n-GET  /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 200\n-GET  /smart_noexport/repo.git/$PACK_URL HTTP/1.1 200\n-GET  /smart_noexport/repo.git/$IDX_URL HTTP/1.1 200\n-\n-###  getanyfile true\n-###\n-GET  /smart/repo.git/HEAD HTTP/1.1 200\n-GET  /smart/repo.git/info/refs HTTP/1.1 200\n-GET  /smart/repo.git/objects/info/packs HTTP/1.1 200\n-GET  /smart/repo.git/objects/info/alternates HTTP/1.1 200 -\n-GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -\n-GET  /smart/repo.git/$LOOSE_URL HTTP/1.1 200\n-GET  /smart/repo.git/$PACK_URL HTTP/1.1 200\n-GET  /smart/repo.git/$IDX_URL HTTP/1.1 200\n-\n-###  getanyfile false\n-###\n-GET  /smart/repo.git/HEAD HTTP/1.1 403 -\n-GET  /smart/repo.git/info/refs HTTP/1.1 403 -\n-GET  /smart/repo.git/objects/info/packs HTTP/1.1 403 -\n-GET  /smart/repo.git/objects/info/alternates HTTP/1.1 403 -\n-GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -\n-GET  /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -\n-GET  /smart/repo.git/$PACK_URL HTTP/1.1 403 -\n-GET  /smart/repo.git/$IDX_URL HTTP/1.1 403 -\n-\n-###  uploadpack default\n-###\n-GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n-POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -\n-\n-###  uploadpack true\n-###\n-GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n-POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -\n-\n-###  uploadpack false\n-###\n-GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -\n-POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -\n-\n-###  receivepack default\n-###\n-GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -\n-POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -\n-\n-###  receivepack true\n-###\n-GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200\n-POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -\n-\n-###  receivepack false\n-###\n-GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -\n-POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -\n-EOF\n-test_expect_success 'server request log matches test results' '\n-\tsed -e \"\n-\t\ts/^.* \\\"//\n-\t\ts/\\\"//\n-\t\ts/ [1-9][0-9]*\\$//\n-\t\ts/^GET /GET  /\n-\t\" >act <\"$HTTPD_ROOT_PATH\"/access.log &&\n-\ttest_cmp exp act\n-'\n-\n-stop_httpd\n-test_done\ndiff --git a/t/t5561-http-backend.sh b/t/t5561-http-backend.sh\nnew file mode 100755\nindex 0000000..8c6d0b2\n--- /dev/null\n+++ b/t/t5561-http-backend.sh\n@@ -0,0 +1,149 @@\n+#!/bin/sh\n+\n+test_description='test git-http-backend'\n+. ./test-lib.sh\n+\n+if test -n \"$NO_CURL\"; then\n+\tsay 'skipping test, git built without http support'\n+\ttest_done\n+fi\n+\n+LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5561'}\n+. \"$TEST_DIRECTORY\"/lib-httpd.sh\n+start_httpd\n+\n+GET() {\n+\tcurl --include \"$HTTPD_URL/$SMART/repo.git/$1\" >out 2>/dev/null &&\n+\ttr '\\015' Q <out |\n+\tsed '\n+\t\ts/Q$//\n+\t\t1q\n+\t' >act &&\n+\techo \"HTTP/1.1 $2\" >exp &&\n+\ttest_cmp exp act\n+}\n+\n+POST() {\n+\tcurl --include --data \"$2\" \\\n+\t--header \"Content-Type: application/x-$1-request\" \\\n+\t\"$HTTPD_URL/smart/repo.git/$1\" >out 2>/dev/null &&\n+\ttr '\\015' Q <out |\n+\tsed '\n+\t\ts/Q$//\n+\t\t1q\n+\t' >act &&\n+\techo \"HTTP/1.1 $3\" >exp &&\n+\ttest_cmp exp act\n+}\n+\n+log_div() {\n+\techo >>\"$HTTPD_ROOT_PATH\"/access.log\n+\techo \"###  $1\" >>\"$HTTPD_ROOT_PATH\"/access.log\n+\techo \"###\" >>\"$HTTPD_ROOT_PATH\"/access.log\n+}\n+\n+. \"$TEST_DIRECTORY\"/t556x_common\n+\n+cat >exp <<EOF\n+\n+###  refs/heads/master\n+###\n+GET  /smart/repo.git/refs/heads/master HTTP/1.1 404 -\n+\n+###  getanyfile default\n+###\n+GET  /smart/repo.git/HEAD HTTP/1.1 200\n+GET  /smart/repo.git/info/refs HTTP/1.1 200\n+GET  /smart/repo.git/objects/info/packs HTTP/1.1 200\n+GET  /smart/repo.git/objects/info/alternates HTTP/1.1 200 -\n+GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -\n+GET  /smart/repo.git/$LOOSE_URL HTTP/1.1 200\n+GET  /smart/repo.git/$PACK_URL HTTP/1.1 200\n+GET  /smart/repo.git/$IDX_URL HTTP/1.1 200\n+\n+###  no git-daemon-export-ok\n+###\n+GET  /smart_noexport/repo.git/HEAD HTTP/1.1 404 -\n+GET  /smart_noexport/repo.git/info/refs HTTP/1.1 404 -\n+GET  /smart_noexport/repo.git/objects/info/packs HTTP/1.1 404 -\n+GET  /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 404 -\n+GET  /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 404 -\n+GET  /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 404 -\n+GET  /smart_noexport/repo.git/$PACK_URL HTTP/1.1 404 -\n+GET  /smart_noexport/repo.git/$IDX_URL HTTP/1.1 404 -\n+\n+###  git-daemon-export-ok\n+###\n+GET  /smart_noexport/repo.git/HEAD HTTP/1.1 200\n+GET  /smart_noexport/repo.git/info/refs HTTP/1.1 200\n+GET  /smart_noexport/repo.git/objects/info/packs HTTP/1.1 200\n+GET  /smart_noexport/repo.git/objects/info/alternates HTTP/1.1 200 -\n+GET  /smart_noexport/repo.git/objects/info/http-alternates HTTP/1.1 200 -\n+GET  /smart_noexport/repo.git/$LOOSE_URL HTTP/1.1 200\n+GET  /smart_noexport/repo.git/$PACK_URL HTTP/1.1 200\n+GET  /smart_noexport/repo.git/$IDX_URL HTTP/1.1 200\n+\n+###  getanyfile true\n+###\n+GET  /smart/repo.git/HEAD HTTP/1.1 200\n+GET  /smart/repo.git/info/refs HTTP/1.1 200\n+GET  /smart/repo.git/objects/info/packs HTTP/1.1 200\n+GET  /smart/repo.git/objects/info/alternates HTTP/1.1 200 -\n+GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 200 -\n+GET  /smart/repo.git/$LOOSE_URL HTTP/1.1 200\n+GET  /smart/repo.git/$PACK_URL HTTP/1.1 200\n+GET  /smart/repo.git/$IDX_URL HTTP/1.1 200\n+\n+###  getanyfile false\n+###\n+GET  /smart/repo.git/HEAD HTTP/1.1 403 -\n+GET  /smart/repo.git/info/refs HTTP/1.1 403 -\n+GET  /smart/repo.git/objects/info/packs HTTP/1.1 403 -\n+GET  /smart/repo.git/objects/info/alternates HTTP/1.1 403 -\n+GET  /smart/repo.git/objects/info/http-alternates HTTP/1.1 403 -\n+GET  /smart/repo.git/$LOOSE_URL HTTP/1.1 403 -\n+GET  /smart/repo.git/$PACK_URL HTTP/1.1 403 -\n+GET  /smart/repo.git/$IDX_URL HTTP/1.1 403 -\n+\n+###  uploadpack default\n+###\n+GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n+POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -\n+\n+###  uploadpack true\n+###\n+GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n+POST /smart/repo.git/git-upload-pack HTTP/1.1 200 -\n+\n+###  uploadpack false\n+###\n+GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 403 -\n+POST /smart/repo.git/git-upload-pack HTTP/1.1 403 -\n+\n+###  receivepack default\n+###\n+GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -\n+POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -\n+\n+###  receivepack true\n+###\n+GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 200\n+POST /smart/repo.git/git-receive-pack HTTP/1.1 200 -\n+\n+###  receivepack false\n+###\n+GET  /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -\n+POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -\n+EOF\n+test_expect_success 'server request log matches test results' '\n+\tsed -e \"\n+\t\ts/^.* \\\"//\n+\t\ts/\\\"//\n+\t\ts/ [1-9][0-9]*\\$//\n+\t\ts/^GET /GET  /\n+\t\" >act <\"$HTTPD_ROOT_PATH\"/access.log &&\n+\ttest_cmp exp act\n+'\n+\n+stop_httpd\n+test_done\ndiff --git a/t/t556x_common b/t/t556x_common\nnew file mode 100755\nindex 0000000..1b4921c\n--- /dev/null\n+++ b/t/t556x_common\n@@ -0,0 +1,119 @@\n+#!/bin/sh\n+\n+find_file() {\n+\tcd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\tfind $1 -type f |\n+\tsed -e 1q\n+}\n+\n+config() {\n+\tgit --git-dir=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" config $1 $2\n+}\n+\n+test_expect_success 'setup repository' '\n+\techo content >file &&\n+\tgit add file &&\n+\tgit commit -m one &&\n+\n+\tmkdir \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t git --bare init &&\n+\t : >objects/info/alternates &&\n+\t : >objects/info/http-alternates\n+\t) &&\n+\tgit remote add public \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\tgit push public master:master &&\n+\n+\t(cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t git repack -a -d\n+\t) &&\n+\n+\techo other >file &&\n+\tgit add file &&\n+\tgit commit -m two &&\n+\tgit push public master:master &&\n+\n+\tLOOSE_URL=$(find_file objects/??) &&\n+\tPACK_URL=$(find_file objects/pack/*.pack) &&\n+\tIDX_URL=$(find_file objects/pack/*.idx)\n+'\n+\n+get_static_files() {\n+\tGET HEAD \"$1\" &&\n+\tGET info/refs \"$1\" &&\n+\tGET objects/info/packs \"$1\" &&\n+\tGET objects/info/alternates \"$1\" &&\n+\tGET objects/info/http-alternates \"$1\" &&\n+\tGET $LOOSE_URL \"$1\" &&\n+\tGET $PACK_URL \"$1\" &&\n+\tGET $IDX_URL \"$1\"\n+}\n+\n+SMART=smart\n+test_expect_success 'direct refs/heads/master not found' '\n+\tlog_div \"refs/heads/master\"\n+\tGET refs/heads/master \"404 Not Found\"\n+'\n+test_expect_success 'static file is ok' '\n+\tlog_div \"getanyfile default\"\n+\tget_static_files \"200 OK\"\n+'\n+SMART=smart_noexport\n+test_expect_success 'no export by default' '\n+\tlog_div \"no git-daemon-export-ok\"\n+\tget_static_files \"404 Not Found\"\n+'\n+test_expect_success 'export if git-daemon-export-ok' '\n+\tlog_div \"git-daemon-export-ok\"\n+        (cd \"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n+\t touch git-daemon-export-ok\n+\t) &&\n+        get_static_files \"200 OK\"\n+'\n+SMART=smart\n+test_expect_success 'static file if http.getanyfile true is ok' '\n+\tlog_div \"getanyfile true\"\n+\tconfig http.getanyfile true &&\n+\tget_static_files \"200 OK\"\n+'\n+test_expect_success 'static file if http.getanyfile false fails' '\n+\tlog_div \"getanyfile false\"\n+\tconfig http.getanyfile false &&\n+\tget_static_files \"403 Forbidden\"\n+'\n+\n+test_expect_success 'http.uploadpack default enabled' '\n+\tlog_div \"uploadpack default\"\n+\tGET info/refs?service=git-upload-pack \"200 OK\"  &&\n+\tPOST git-upload-pack 0000 \"200 OK\"\n+'\n+test_expect_success 'http.uploadpack true' '\n+\tlog_div \"uploadpack true\"\n+\tconfig http.uploadpack true &&\n+\tGET info/refs?service=git-upload-pack \"200 OK\" &&\n+\tPOST git-upload-pack 0000 \"200 OK\"\n+'\n+test_expect_success 'http.uploadpack false' '\n+\tlog_div \"uploadpack false\"\n+\tconfig http.uploadpack false &&\n+\tGET info/refs?service=git-upload-pack \"403 Forbidden\" &&\n+\tPOST git-upload-pack 0000 \"403 Forbidden\"\n+'\n+\n+test_expect_success 'http.receivepack default disabled' '\n+\tlog_div \"receivepack default\"\n+\tGET info/refs?service=git-receive-pack \"403 Forbidden\"  &&\n+\tPOST git-receive-pack 0000 \"403 Forbidden\"\n+'\n+test_expect_success 'http.receivepack true' '\n+\tlog_div \"receivepack true\"\n+\tconfig http.receivepack true &&\n+\tGET info/refs?service=git-receive-pack \"200 OK\" &&\n+\tPOST git-receive-pack 0000 \"200 OK\"\n+'\n+test_expect_success 'http.receivepack false' '\n+\tlog_div \"receivepack false\"\n+\tconfig http.receivepack false &&\n+\tGET info/refs?service=git-receive-pack \"403 Forbidden\" &&\n+\tPOST git-receive-pack 0000 \"403 Forbidden\"\n+'\n-- \n1.6.6.236.gc56f3\n"},{"id":"130712","messageId":"1262468287-8629-3-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":"20100102205928.GM6914@spearce.org","subject":"[PATCH v4 3/3] Smart-http tests: Test http-backend without curl or a webserver","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2010-01-02T21:38:07Z","receivedAt":"2010-01-02T21:38:07Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"This reuses many of the tests from the old t5560 but runs those tests\nwithout curl or a webserver.  This will hopefully increase the testing\ncoverage for http-backend because it does not require users to set\nGIT_TEST_HTTPD.\n\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n---\nAs a side note, I am very impressed that git rebase was able to\napply this patch properly even after I renamed the tests earlier in\nthe series.\n---\n t/t5560-http-backend-noserver.sh |   30 ++++++++++++++++++++++++------\n t/t556x_common                   |    3 +++\n 2 files changed, 27 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh\nindex a9ba2d9..9013824 100755\n--- a/t/t5560-http-backend-noserver.sh\n+++ b/t/t5560-http-backend-noserver.sh\n@@ -6,18 +6,36 @@ test_description='test git-http-backend-noserver'\n HTTPD_DOCUMENT_ROOT_PATH=\"$TRASH_DIRECTORY\"\n \n run_backend() {\n-\tREQUEST_METHOD=GET \\\n+\techo \"$2\"| \\\n+\tQUERY_STRING=\"${1#*\\?}\" \\\n \tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n-\tPATH_INFO=\"$1\" \\\n+\tPATH_INFO=\"${1%%\\?*}\" \\\n \tgit http-backend >act.out 2>act.err\n }\n \n GET() {\n-\treturn 0\n+\tREQUEST_METHOD=\"GET\" \\\n+\trun_backend \"/repo.git/$1\" &&\n+\tgrep \"Status\" act.out >act\n+\tif [ $? -eq 1 ];\n+\tthen\n+\t\tprintf \"Status: 200 OK\\r\\n\" > act\n+\tfi\n+\tprintf \"Status: $2\\r\\n\" > exp &&\n+\ttest_cmp exp act\n }\n \n POST() {\n-\treturn 0\n+\tREQUEST_METHOD=\"POST\" \\\n+\tCONTENT_TYPE=\"application/x-$1-request\" \\\n+\trun_backend \"/repo.git/$1\" \"$2\" &&\n+\tgrep \"Status\" act.out >act\n+\tif [ $? -eq 1 ];\n+\tthen\n+\t\tprintf \"Status: 200 OK\\r\\n\" > act\n+\tfi\n+\tprintf \"Status: $3\\r\\n\" > exp &&\n+\ttest_cmp exp act\n }\n \n log_div() {\n@@ -28,9 +46,9 @@ log_div() {\n \n expect_aliased() {\n \tif test $1 = 0; then\n-\t\trun_backend \"$2\"\n+\t\tREQUEST_METHOD=GET run_backend \"$2\"\n \telse\n-\t\trun_backend \"$2\" &&\n+\t\tREQUEST_METHOD=GET run_backend \"$2\" &&\n \t\techo \"fatal: '$2': aliased\" >exp.err &&\n \t\ttest_cmp exp.err act.err\n \tfi\ndiff --git a/t/t556x_common b/t/t556x_common\nindex 1b4921c..be024e5 100755\n--- a/t/t556x_common\n+++ b/t/t556x_common\n@@ -50,6 +50,7 @@ get_static_files() {\n }\n \n SMART=smart\n+export GIT_HTTP_EXPORT_ALL=1\n test_expect_success 'direct refs/heads/master not found' '\n \tlog_div \"refs/heads/master\"\n \tGET refs/heads/master \"404 Not Found\"\n@@ -59,6 +60,7 @@ test_expect_success 'static file is ok' '\n \tget_static_files \"200 OK\"\n '\n SMART=smart_noexport\n+unset GIT_HTTP_EXPORT_ALL\n test_expect_success 'no export by default' '\n \tlog_div \"no git-daemon-export-ok\"\n \tget_static_files \"404 Not Found\"\n@@ -71,6 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' '\n         get_static_files \"200 OK\"\n '\n SMART=smart\n+export GIT_HTTP_EXPORT_ALL=1\n test_expect_success 'static file if http.getanyfile true is ok' '\n \tlog_div \"getanyfile true\"\n \tconfig http.getanyfile true &&\n-- \n1.6.6.236.gc56f3\n"},{"id":"130714","messageId":"20100102214107.GO6914@spearce.org","threadId":"22042","inReplyTo":"905315641001021337v238515c8s34d820236dac698d@mail.gmail.com","subject":"Re: [PATCH v3 3/3] Smart-http tests: Test http-backend without curl or a webserver","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2010-01-02T21:41:07Z","receivedAt":"2010-01-02T21:41:07Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Tarmigan <tarmigan+git@gmail.com> wrote:\n> On Sat, Jan 2, 2010 at 1:03 PM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> > Tarmigan Casebolt <tarmigan+git@gmail.com> wrote:\n> >> ?GET() {\n> >> - ? ? return 0\n> >> + ? ? REQUEST_METHOD=\"GET\" \\\n> >> + ? ? run_backend \"/repo.git/$1\" &&\n> >> + ? ? grep \"Status\" act.out >act\n> >> + ? ? if [ $? -eq 1 ];\n> >\n> > I think this should be spelled as:\n> >\n> > ? ? ? ?if ! grep \"Status\" act.out >act; then\n> > ? ? ? ? ? ? ? ?printf \"Status: 200 OK\\r\\n\" > act\n> > ? ? ? ?fi\n> \n> OK.  I had figured the \"1\" would mean \"no matches not found\"  rather\n> than some other error like \"file does not exist\".  Not sure how\n> portable that error value convention is for greps though, so I've\n> changed it as you suggested.\n\nYour v3 series still shows it the old way...\n\n-- \nShawn.\n"},{"id":"130715","messageId":"1262468639-8847-1-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":"20100102214107.GO6914@spearce.org","subject":"[PATCH v4 3/3] Smart-http tests: Test http-backend without curl or a webserver","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2010-01-02T21:43:59Z","receivedAt":"2010-01-02T21:43:59Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"This reuses many of the tests from the old t5560 but runs those tests\nwithout curl or a webserver.  This will hopefully increase the testing\ncoverage for http-backend because it does not require users to set\nGIT_TEST_HTTPD.\n\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n---\nOops forgot to commit the grep changes.\n\nOnly resending 3/3 of the series.\n---\n t/t5560-http-backend-noserver.sh |   26 ++++++++++++++++++++------\n t/t556x_common                   |    3 +++\n 2 files changed, 23 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh\nindex a9ba2d9..a63d3ec 100755\n--- a/t/t5560-http-backend-noserver.sh\n+++ b/t/t5560-http-backend-noserver.sh\n@@ -6,18 +6,32 @@ test_description='test git-http-backend-noserver'\n HTTPD_DOCUMENT_ROOT_PATH=\"$TRASH_DIRECTORY\"\n \n run_backend() {\n-\tREQUEST_METHOD=GET \\\n+\techo \"$2\"| \\\n+\tQUERY_STRING=\"${1#*\\?}\" \\\n \tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n-\tPATH_INFO=\"$1\" \\\n+\tPATH_INFO=\"${1%%\\?*}\" \\\n \tgit http-backend >act.out 2>act.err\n }\n \n GET() {\n-\treturn 0\n+\tREQUEST_METHOD=\"GET\" \\\n+\trun_backend \"/repo.git/$1\" &&\n+\tif ! grep \"Status\" act.out >act; then\n+\t\tprintf \"Status: 200 OK\\r\\n\" > act\n+\tfi\n+\tprintf \"Status: $2\\r\\n\" > exp &&\n+\ttest_cmp exp act\n }\n \n POST() {\n-\treturn 0\n+\tREQUEST_METHOD=\"POST\" \\\n+\tCONTENT_TYPE=\"application/x-$1-request\" \\\n+\trun_backend \"/repo.git/$1\" \"$2\" &&\n+\tif ! grep \"Status\" act.out >act; then\n+\t\tprintf \"Status: 200 OK\\r\\n\" > act\n+\tfi\n+\tprintf \"Status: $3\\r\\n\" > exp &&\n+\ttest_cmp exp act\n }\n \n log_div() {\n@@ -28,9 +42,9 @@ log_div() {\n \n expect_aliased() {\n \tif test $1 = 0; then\n-\t\trun_backend \"$2\"\n+\t\tREQUEST_METHOD=GET run_backend \"$2\"\n \telse\n-\t\trun_backend \"$2\" &&\n+\t\tREQUEST_METHOD=GET run_backend \"$2\" &&\n \t\techo \"fatal: '$2': aliased\" >exp.err &&\n \t\ttest_cmp exp.err act.err\n \tfi\ndiff --git a/t/t556x_common b/t/t556x_common\nindex 1b4921c..be024e5 100755\n--- a/t/t556x_common\n+++ b/t/t556x_common\n@@ -50,6 +50,7 @@ get_static_files() {\n }\n \n SMART=smart\n+export GIT_HTTP_EXPORT_ALL=1\n test_expect_success 'direct refs/heads/master not found' '\n \tlog_div \"refs/heads/master\"\n \tGET refs/heads/master \"404 Not Found\"\n@@ -59,6 +60,7 @@ test_expect_success 'static file is ok' '\n \tget_static_files \"200 OK\"\n '\n SMART=smart_noexport\n+unset GIT_HTTP_EXPORT_ALL\n test_expect_success 'no export by default' '\n \tlog_div \"no git-daemon-export-ok\"\n \tget_static_files \"404 Not Found\"\n@@ -71,6 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' '\n         get_static_files \"200 OK\"\n '\n SMART=smart\n+export GIT_HTTP_EXPORT_ALL=1\n test_expect_success 'static file if http.getanyfile true is ok' '\n \tlog_div \"getanyfile true\"\n \tconfig http.getanyfile true &&\n-- \n1.6.6.236.gc56f3\n"},{"id":"131581","messageId":"4B4EAB58.6040901@alum.mit.edu","threadId":"22042","inReplyTo":"1262468639-8847-1-git-send-email-tarmigan+git@gmail.com","subject":"Re: [PATCH v4 3/3] Smart-http tests: Test http-backend without curl or a webserver","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2010-01-14T05:27:52Z","receivedAt":"2010-01-14T05:27:52Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"Tarmigan Casebolt wrote:\n> This reuses many of the tests from the old t5560 but runs those tests\n> without curl or a webserver.  This will hopefully increase the testing\n> coverage for http-backend because it does not require users to set\n> GIT_TEST_HTTPD.\n> \n> Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n\nI'm not sure which version of this patch is currently committed, but in\nany case test t/t5560-http-backend-noserver.sh is broken for me in\n\"next\".  According to git-bisect, the guilty commit is\n\nfd0a8c2e6428acb883bf4707de54b3e026c57455 'Smart-http tests: Test\nhttp-backend without curl or a webserver'\n\nI'm not familiar with this part of the code and I haven't done any\nspecial setup (e.g., I have not set GIT_TEST_HTTPD, whatever that is).\nSimply checking out, \"make\"ing, then running\nt5560-http-backend-noserver.sh results in 13/14 failures starting with\ntest 2:\n\n> \n> * expecting success: \n> \tlog_div \"refs/heads/master\"\n> \tGET refs/heads/master \"404 Not Found\"\n> \n> --- exp\t2010-01-14 05:21:34.000000000 +0000\n> +++ act\t2010-01-14 05:21:34.000000000 +0000\n> @@ -1 +1 @@\n> -Status: 404 Not Found\n> +Status: 500 Internal Server Error\n> * FAIL 2: direct refs/heads/master not found\n\nThis failure is on Ubuntu Linux 8.04 \"hardy\".\n\nPlease let me know if I am doing something wrong or if you would like\nany more information.\n\nMichael\n"},{"id":"131606","messageId":"1263452477-15250-1-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":"4B4EAB58.6040901@alum.mit.edu","subject":"[PATCH] Test t5560: Fix test when run with dash","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2010-01-14T07:01:17Z","receivedAt":"2010-01-14T07:01:17Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"dash is more finicky than some shells and this change seems to make it\nhappier.\n\nReported-by: Michael Haggerty <mhagger@alum.mit.edu>\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n\n---\nMichael, thanks for the report.\n\nUbuntu's /bin/sh is dash, which I had not tested with.  Installing\ndash on my machine, I was able to reproduce and this patch fixes the\nproblem for me.\n\nCould you please see if this works for you?\n\nThanks,\nTarmigan\n---\n t/t5560-http-backend-noserver.sh |    9 ++++-----\n 1 files changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh\nindex 5f8c88e..f2e413d 100755\n--- a/t/t5560-http-backend-noserver.sh\n+++ b/t/t5560-http-backend-noserver.sh\n@@ -10,12 +10,13 @@ run_backend() {\n \tQUERY_STRING=\"${1#*\\?}\" \\\n \tGIT_PROJECT_ROOT=\"$HTTPD_DOCUMENT_ROOT_PATH\" \\\n \tPATH_INFO=\"${1%%\\?*}\" \\\n+\tREQUEST_METHOD=\"$3\" \\\n+\tCONTENT_TYPE=\"$4\" \\\n \tgit http-backend >act.out 2>act.err\n }\n \n GET() {\n-\tREQUEST_METHOD=\"GET\" \\\n-\trun_backend \"/repo.git/$1\" &&\n+\trun_backend \"/repo.git/$1\" \"\" \"GET\" &&\n \tif ! grep \"Status\" act.out >act\n \tthen\n \t\tprintf \"Status: 200 OK\\r\\n\" >act\n@@ -25,9 +26,7 @@ GET() {\n }\n \n POST() {\n-\tREQUEST_METHOD=\"POST\" \\\n-\tCONTENT_TYPE=\"application/x-$1-request\" \\\n-\trun_backend \"/repo.git/$1\" \"$2\" &&\n+\trun_backend \"/repo.git/$1\" \"$2\" \"POST\" \"application/x-$1-request\" &&\n \tif ! grep \"Status\" act.out >act\n \tthen\n \t\tprintf \"Status: 200 OK\\r\\n\" >act\n-- \n1.6.6.376.gabe8e\n"},{"id":"131615","messageId":"4B4ED47C.1050300@alum.mit.edu","threadId":"22042","inReplyTo":"1263452477-15250-1-git-send-email-tarmigan+git@gmail.com","subject":"Re: [PATCH] Test t5560: Fix test when run with dash","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2010-01-14T08:23:24Z","receivedAt":"2010-01-14T08:23:24Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"Tarmigan Casebolt wrote:\n> dash is more finicky than some shells and this change seems to make it\n> happier.\n> \n> Reported-by: Michael Haggerty <mhagger@alum.mit.edu>\n> Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n> \n> ---\n> Michael, thanks for the report.\n> \n> Ubuntu's /bin/sh is dash, which I had not tested with.  Installing\n> dash on my machine, I was able to reproduce and this patch fixes the\n> problem for me.\n> \n> Could you please see if this works for you?\n> [...]\n\nYes, that fixes it.  Thanks!\n\nMichael\n"},{"id":"131618","messageId":"7vfx69hyd5.fsf@alter.siamese.dyndns.org","threadId":"22042","inReplyTo":"1263452477-15250-1-git-send-email-tarmigan+git@gmail.com","subject":"Re: [PATCH] Test t5560: Fix test when run with dash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-14T08:41:42Z","receivedAt":"2010-01-14T08:41:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tarmigan Casebolt <tarmigan+git@gmail.com> writes:\n\n> dash is more finicky than some shells and this change seems to make it\n> happier.\n\n\"Finicky\" won't help other people to learn what to avoid making the same\nmistake in the future.  Please spell the problem out more explicitly.\n\nI think the issue is that some shells do not like the \"Run this command\n(and only this command) under these environment variable settings\"\n\n\tVAR1=VAL1 VAR2=VAL2 command\n\nif \"command\" is a shell function.\n\nDoes that match your understanding of the problem?\n"},{"id":"131703","messageId":"1263537842-5792-1-git-send-email-tarmigan+git@gmail.com","threadId":"22042","inReplyTo":"7vfx69hyd5.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] Test t5560: Fix test when run with dash","fromName":"Tarmigan Casebolt","fromEmail":"tarmigan+git@gmail.com","sentAt":"2010-01-15T06:44:02Z","receivedAt":"2010-01-15T06:44:02Z","isPatch":true,"sender":{"key":"tarmigan+git@gmail.com","avatar":null},"body":"The dash shell is more finicky than some others.\n\nIn particular, it does not seem to like the pattern of setting an\nenvironment variable on the same line as you call a shell function\nlike this:\n\n        REQUEST_METHOD=\"GET\" some_shell_function\n\nas you might use to set a variable only for one command if that\ncommand were an executable or a shell builtin.\n\nReported-by: Michael Haggerty <mhagger@alum.mit.edu>\nSigned-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>\n---\nJunio, that description matches my understanding of the problem.\nI can't tell from my reading of the POSIX spec whether my usage was\nwrong or if dash is wrong, which is why I shied away from an\nexplanation.  As a practical matter though, this patch does fix the\nissue.\n\nThis version takes a slighty different approach that I think leaves\nthings clearer and doesn't pass in tons of arguements to the shell\nfunction.  If you prefer the old approach, I can send a patch that way\ninstead.\n---\n t/t5560-http-backend-noserver.sh |   15 ++++++++++-----\n 1 files changed, 10 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh\nindex 5f8c88e..44885b8 100755\n--- a/t/t5560-http-backend-noserver.sh\n+++ b/t/t5560-http-backend-noserver.sh\n@@ -14,8 +14,9 @@ run_backend() {\n }\n \n GET() {\n-\tREQUEST_METHOD=\"GET\" \\\n+\texport REQUEST_METHOD=\"GET\" &&\n \trun_backend \"/repo.git/$1\" &&\n+\tunset REQUEST_METHOD &&\n \tif ! grep \"Status\" act.out >act\n \tthen\n \t\tprintf \"Status: 200 OK\\r\\n\" >act\n@@ -25,9 +26,11 @@ GET() {\n }\n \n POST() {\n-\tREQUEST_METHOD=\"POST\" \\\n-\tCONTENT_TYPE=\"application/x-$1-request\" \\\n+\texport REQUEST_METHOD=\"POST\" &&\n+\texport CONTENT_TYPE=\"application/x-$1-request\" &&\n \trun_backend \"/repo.git/$1\" \"$2\" &&\n+\tunset REQUEST_METHOD &&\n+\tunset CONTENT_TYPE &&\n \tif ! grep \"Status\" act.out >act\n \tthen\n \t\tprintf \"Status: 200 OK\\r\\n\" >act\n@@ -43,13 +46,15 @@ log_div() {\n . \"$TEST_DIRECTORY\"/t556x_common\n \n expect_aliased() {\n+\texport REQUEST_METHOD=\"GET\" &&\n \tif test $1 = 0; then\n-\t\tREQUEST_METHOD=GET run_backend \"$2\"\n+\t\trun_backend \"$2\"\n \telse\n-\t\tREQUEST_METHOD=GET run_backend \"$2\" &&\n+\t\trun_backend \"$2\" &&\n \t\techo \"fatal: '$2': aliased\" >exp.err &&\n \t\ttest_cmp exp.err act.err\n \tfi\n+\tunset REQUEST_METHOD\n }\n \n test_expect_success 'http-backend blocks bad PATH_INFO' '\n-- \n1.6.6\n"},{"id":"131710","messageId":"4B5027B8.2090507@viscovery.net","threadId":"22042","inReplyTo":"1263537842-5792-1-git-send-email-tarmigan+git@gmail.com","subject":"Re: [PATCH v2] Test t5560: Fix test when run with dash","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-01-15T08:30:48Z","receivedAt":"2010-01-15T08:30:48Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Tarmigan Casebolt schrieb:\n>         REQUEST_METHOD=\"GET\" some_shell_function\n\n> I can't tell from my reading of the POSIX spec whether my usage was\n> wrong or if dash is wrong,\n\nAccording to POSIX, variables set as shown above for shell functions are\nnot exported and retain their value after the function returns. I would\nnot be surprised if dash got this right, and the tests fail because they\nwere written for bash, which gets it wrong.\n\nIn particular,\n\nf() { sh -c 'echo +$v+'; }\nv=x f\necho +$v+\nsh -c 'echo +$v+'\"\n\nShould print\n\n++\n+x+\n++\n\nI can test only ash, bash, zsh, and ksh, of which only ksh gets it right.\n\n-- Hannes\n"},{"id":"131746","messageId":"7vljfzz0yd.fsf@alter.siamese.dyndns.org","threadId":"22042","inReplyTo":"4B5027B8.2090507@viscovery.net","subject":"Re: [PATCH v2] Test t5560: Fix test when run with dash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-15T18:18:18Z","receivedAt":"2010-01-15T18:18:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> Tarmigan Casebolt schrieb:\n>>         REQUEST_METHOD=\"GET\" some_shell_function\n>\n>> I can't tell from my reading of the POSIX spec whether my usage was\n>> wrong or if dash is wrong,\n>\n> According to POSIX, variables set as shown above for shell functions are\n> not exported and retain their value after the function returns.\n\nI actually looked for this yesterday, but didn't find a relevant\ndefinition.  But \"2.9.5 Function Definition Command\" [*1*] seems to\naddress the issue: \"When a function is executed, it shall have the\nsyntax-error and variable-assignment properties described for special\nbuilt-in utilities...\".\n\nAnd \"2.14 Special Built-in Utilities\" section [*2*] says \"2. Variable\nassignments specified with special built-in utilities remain in effect\nafter the built-in completes...\".  Taking both together, it seems that\nthe assignment should be in effect after the function returns.\n\nDoes my reading match yours, or do you have more definitive descriptions\nyou can point at in POSIX.1, so that the log message can be improved to\nhelp people avoid this issue in the future?\n\nYesterday, I saw rebase--interactive has a few codepaths where \"output\"\nshell function was used with the single-shot export; perhaps they need to\nalso be fixed.\n\n[References]\n\n*1* http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_05\n*2* http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14\n"},{"id":"131751","messageId":"201001152017.00121.j6t@kdbg.org","threadId":"22042","inReplyTo":"7vljfzz0yd.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] Test t5560: Fix test when run with dash","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-01-15T19:16:59Z","receivedAt":"2010-01-15T19:16:59Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Freitag, 15. Januar 2010, Junio C Hamano wrote:\n> Johannes Sixt <j.sixt@viscovery.net> writes:\n> > Tarmigan Casebolt schrieb:\n> >>         REQUEST_METHOD=\"GET\" some_shell_function\n> >>\n> >> I can't tell from my reading of the POSIX spec whether my usage was\n> >> wrong or if dash is wrong,\n> >\n> > According to POSIX, variables set as shown above for shell functions are\n> > not exported and retain their value after the function returns.\n>\n> I actually looked for this yesterday, but didn't find a relevant\n> definition.  But \"2.9.5 Function Definition Command\" [*1*] seems to\n> address the issue: \"When a function is executed, it shall have the\n> syntax-error and variable-assignment properties described for special\n> built-in utilities...\".\n>\n> And \"2.14 Special Built-in Utilities\" section [*2*] says \"2. Variable\n> assignments specified with special built-in utilities remain in effect\n> after the built-in completes...\".  Taking both together, it seems that\n> the assignment should be in effect after the function returns.\n>\n> Does my reading match yours,\n\nThese are exactly the definitions that I meant. The statement that variables \nare not exported is in \"2.9.1 Simple Commands\" \nhttp://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01\n\n\"[If there is a command name], the variable assignments shall be exported for \nthe execution environment of the command and shall not affect the current \nexecution environment (except for special built-ins).\"\n\n> Yesterday, I saw rebase--interactive has a few codepaths where \"output\"\n> shell function was used with the single-shot export; perhaps they need to\n> also be fixed.\n\nI knew these spots, and they were discussed when that code was introduced. \nBefore I sent out the mail you were responding to, I tried various ways to \nshow the failure in rebase--interactive, but it didn't fail...\n\n-- Hannes\n"},{"id":"131756","messageId":"7vr5prxhz4.fsf@alter.siamese.dyndns.org","threadId":"22042","inReplyTo":"201001152017.00121.j6t@kdbg.org","subject":"Re: [PATCH v2] Test t5560: Fix test when run with dash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-15T19:53:35Z","receivedAt":"2010-01-15T19:53:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> These are exactly the definitions that I meant. The statement that variables \n> are not exported is in \"2.9.1 Simple Commands\" \n> http://www.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01\n>\n> \"[If there is a command name], the variable assignments shall be exported for \n> the execution environment of the command and shall not affect the current \n> execution environment (except for special built-ins).\"\n\nNote the \"except for special built-ins\".  I was unsure yesterday because\nit does not say \"except for special built-ins and shell functions\".\n"},{"id":"131834","messageId":"7v4ommoo4p.fsf@alter.siamese.dyndns.org","threadId":"22042","inReplyTo":"201001152017.00121.j6t@kdbg.org","subject":"Re: [PATCH v2] Test t5560: Fix test when run with dash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-01-16T01:05:26Z","receivedAt":"2010-01-16T01:05:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n>> Yesterday, I saw rebase--interactive has a few codepaths where \"output\"\n>> shell function was used with the single-shot export; perhaps they need to\n>> also be fixed.\n>\n> I knew these spots, and they were discussed when that code was introduced. \n> Before I sent out the mail you were responding to, I tried various ways to \n> show the failure in rebase--interactive, but it didn't fail...\n\nIt may be the case that the single-shot-ness of these GIT_AUTHOR_NAME\nexports do not matter at all in that program, even though the original\nversions may have been written carefully not to leak the value suitable\nfor the current commit to later rounds.\n\nI think the recent updates from Michael actually depends on the\ndistinction not to matter.  For example, do_with_author() in 7756ecf\n(rebase -i: Extract function do_with_author, 2010-01-14) invokes \"$@\"\nthat could be a shell function.\n"},{"id":"132305","messageId":"4B587DAE.9030208@alum.mit.edu","threadId":"22042","inReplyTo":"7v4ommoo4p.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2] Test t5560: Fix test when run with dash","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2010-01-21T16:15:42Z","receivedAt":"2010-01-21T16:15:42Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"Junio C Hamano wrote:\n> Johannes Sixt <j6t@kdbg.org> writes:\n>>> Yesterday, I saw rebase--interactive has a few codepaths where \"output\"\n>>> shell function was used with the single-shot export; perhaps they need to\n>>> also be fixed.\n>> I knew these spots, and they were discussed when that code was introduced. \n>> Before I sent out the mail you were responding to, I tried various ways to \n>> show the failure in rebase--interactive, but it didn't fail...\n> \n> It may be the case that the single-shot-ness of these GIT_AUTHOR_NAME\n> exports do not matter at all in that program, even though the original\n> versions may have been written carefully not to leak the value suitable\n> for the current commit to later rounds.\n> \n> I think the recent updates from Michael actually depends on the\n> distinction not to matter.  For example, do_with_author() in 7756ecf\n> (rebase -i: Extract function do_with_author, 2010-01-14) invokes \"$@\"\n> that could be a shell function.\n\nI have to say that I am a little bit over my head here.  I didn't try to\nfollow the complete data path of the GIT_AUTHOR_* shell variables, nor\ndo I know exactly what git commands they affect.  I just tried to\nlocally refactor the code based on my mistaken assumption that shell\nfunctions are treated much like external commands WRT export of shell\nvariables.\n\nThe use of the GIT_AUTHOR_* variables in git-rebase--interactive.sh were\nand are a bit peculiar anyway, since the variables are already set\nbefore do_with_author() is invoked, and the values are left to hang\naround afterwards.  The do_with_author() function only tries to export\nthese already-set variables.\n\nSo I suppose that the simplest solution is to export these variables\nexplicitly in do_with_author(), something like this (similar to the\nthird code block that was replaced by the do_with_author() function):\n\ndo_with_author() {\n\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE &&\n\t\"$@\"\n}\n\nBut to ensure that this is a correct solution would require verification\nthat these now-exported variables don't cause unwanted side-effects\nduring any other external command invocations.  Alternatively, I suppose\nthat the variables could be exported within a subshell that also invokes\nthe \"$@\" command; this subshell could even source the $AUTHOR_SCRIPT\nfile if it were thought advantageous not to set the GIT_AUTHOR_*\nvariables in the git-rebase--interactive.sh script at all.\n\nHelp would be most appreciated; I probably won't have time to work on\nthis myself for a week or two.\n\nMichael\n"}]}