Merge branch 'nd/http-fetch-shallow-fix'
authorJunio C Hamano <gitster@pobox.com>
Thu, 27 Feb 2014 22:01:50 +0000 (14:01 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Feb 2014 22:01:50 +0000 (14:01 -0800)
Attempting to deepen a shallow repository by fetching over smart
HTTP transport failed in the protocol exchange, when no-done
extension was used. The fetching side waited for the list of
shallow boundary commits after the sending end stopped talking to
it.

* nd/http-fetch-shallow-fix:
t5537: move http tests out to t5539
fetch-pack: fix deepen shallow over smart http with no-done cap
protocol-capabilities.txt: document no-done
protocol-capabilities.txt: refer multi_ack_detailed back to pack-protocol.txt
pack-protocol.txt: clarify 'obj-id' in the last ACK after 'done'
test: rename http fetch and push test files

13 files changed:
Documentation/technical/pack-protocol.txt
Documentation/technical/protocol-capabilities.txt
fetch-pack.c
t/t5537-fetch-shallow.sh
t/t5539-fetch-http-shallow.sh [new file with mode: 0755]
t/t5540-http-push-webdav.sh [new file with mode: 0755]
t/t5540-http-push.sh [deleted file]
t/t5541-http-push-smart.sh [new file with mode: 0755]
t/t5541-http-push.sh [deleted file]
t/t5550-http-fetch-dumb.sh [new file with mode: 0755]
t/t5550-http-fetch.sh [deleted file]
t/t5551-http-fetch-smart.sh [new file with mode: 0755]
t/t5551-http-fetch.sh [deleted file]
index c73b62f5e1ced76d783dcd5e7aef64016ca1fb4c..39c64105a61a3743da0c8c3b04ee31106090cfa7 100644 (file)
@@ -338,7 +338,8 @@ during a prior round.  This helps to ensure that at least one common
 ancestor is found before we give up entirely.
 
 Once the 'done' line is read from the client, the server will either
-send a final 'ACK obj-id' or it will send a 'NAK'. The server only sends
+send a final 'ACK obj-id' or it will send a 'NAK'. 'obj-id' is the object
+name of the last commit determined to be common. The server only sends
 ACK after 'done' if there is at least one common base and multi_ack or
 multi_ack_detailed is enabled. The server always sends NAK after 'done'
 if there is no common base found.
index e3e792476e7a6b7554582469b2c5ac172b2f17dd..e17434384724662aabb60d7fceed40a433207608 100644 (file)
@@ -69,6 +69,24 @@ ends.
 Without multi_ack the client would have sent that c-b-a chain anyway,
 interleaved with S-R-Q.
 
+multi_ack_detailed
+------------------
+This is an extension of multi_ack that permits client to better
+understand the server's in-memory state. See pack-protocol.txt,
+section "Packfile Negotiation" for more information.
+
+no-done
+-------
+This capability should only be used with the smart HTTP protocol. If
+multi_ack_detailed and no-done are both present, then the sender is
+free to immediately send a pack following its first "ACK obj-id ready"
+message.
+
+Without no-done in the smart HTTP protocol, the server session would
+end and the client has to make another trip to send "done" before
+the server can send the pack. no-done removes the last round and
+thus slightly reduces latency.
+
 thin-pack
 ---------
 
index 90fdd49821a1d6d3e104124444e37ac4b9b03fa2..f061f1fe85ea20549f860c4bf37980941f480833 100644 (file)
@@ -439,7 +439,8 @@ static int find_common(struct fetch_pack_args *args,
        }
        strbuf_release(&req_buf);
 
-       consume_shallow_list(args, fd[0]);
+       if (!got_ready || !no_done)
+               consume_shallow_list(args, fd[0]);
        while (flushes || multi_ack) {
                int ack = get_ack(fd[0], result_sha1);
                if (ack) {
index adf215a1937cf2ab2049e3e942497860e49d67cb..3ae9092f5c2511e075c1bf6c215ea773f738f1f9 100755 (executable)
@@ -173,31 +173,4 @@ EOF
        )
 '
 
-if test -n "$NO_CURL" -o -z "$GIT_TEST_HTTPD"; then
-       say 'skipping remaining tests, git built without http support'
-       test_done
-fi
-
-. "$TEST_DIRECTORY"/lib-httpd.sh
-start_httpd
-
-test_expect_success 'clone http repository' '
-       git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
-       git clone $HTTPD_URL/smart/repo.git clone &&
-       (
-       cd clone &&
-       git fsck &&
-       git log --format=%s origin/master >actual &&
-       cat <<EOF >expect &&
-7
-6
-5
-4
-3
-EOF
-       test_cmp expect actual
-       )
-'
-
-stop_httpd
 test_done
diff --git a/t/t5539-fetch-http-shallow.sh b/t/t5539-fetch-http-shallow.sh
new file mode 100755 (executable)
index 0000000..94553e1
--- /dev/null
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+test_description='fetch/clone from a shallow clone over http'
+
+. ./test-lib.sh
+
+if test -n "$NO_CURL"; then
+       skip_all='skipping test, git built without http support'
+       test_done
+fi
+
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+commit() {
+       echo "$1" >tracked &&
+       git add tracked &&
+       git commit -m "$1"
+}
+
+test_expect_success 'setup shallow clone' '
+       commit 1 &&
+       commit 2 &&
+       commit 3 &&
+       commit 4 &&
+       commit 5 &&
+       commit 6 &&
+       commit 7 &&
+       git clone --no-local --depth=5 .git shallow &&
+       git config --global transfer.fsckObjects true
+'
+
+test_expect_success 'clone http repository' '
+       git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+       git clone $HTTPD_URL/smart/repo.git clone &&
+       (
+       cd clone &&
+       git fsck &&
+       git log --format=%s origin/master >actual &&
+       cat <<EOF >expect &&
+7
+6
+5
+4
+3
+EOF
+       test_cmp expect actual
+       )
+'
+
+# This test is tricky. We need large enough "have"s that fetch-pack
+# will put pkt-flush in between. Then we need a "have" the server
+# does not have, it'll send "ACK %s ready"
+test_expect_success 'no shallow lines after receiving ACK ready' '
+       (
+               cd shallow &&
+               for i in $(test_seq 15)
+               do
+                       git checkout --orphan unrelated$i &&
+                       test_commit unrelated$i &&
+                       git push -q "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
+                               refs/heads/unrelated$i:refs/heads/unrelated$i &&
+                       git push -q ../clone/.git \
+                               refs/heads/unrelated$i:refs/heads/unrelated$i ||
+                       exit 1
+               done &&
+               git checkout master &&
+               test_commit new &&
+               git push  "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" master
+       ) &&
+       (
+               cd clone &&
+               git checkout --orphan newnew &&
+               test_commit new-too &&
+               GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" git fetch --depth=2 &&
+               grep "fetch-pack< ACK .* ready" ../trace &&
+               ! grep "fetch-pack> done" ../trace
+       )
+'
+
+stop_httpd
+test_done
diff --git a/t/t5540-http-push-webdav.sh b/t/t5540-http-push-webdav.sh
new file mode 100755 (executable)
index 0000000..8d7b3c5
--- /dev/null
@@ -0,0 +1,181 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
+#
+
+test_description='test WebDAV http-push
+
+This test runs various sanity checks on http-push.'
+
+. ./test-lib.sh
+
+if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
+then
+       skip_all="skipping test, USE_CURL_MULTI is not defined"
+       test_done
+fi
+
+LIB_HTTPD_DAV=t
+. "$TEST_DIRECTORY"/lib-httpd.sh
+ROOT_PATH="$PWD"
+start_httpd
+
+test_expect_success 'setup remote repository' '
+       cd "$ROOT_PATH" &&
+       mkdir test_repo &&
+       cd test_repo &&
+       git init &&
+       : >path1 &&
+       git add path1 &&
+       test_tick &&
+       git commit -m initial &&
+       cd - &&
+       git clone --bare test_repo test_repo.git &&
+       cd test_repo.git &&
+       git --bare update-server-info &&
+       mv hooks/post-update.sample hooks/post-update &&
+       ORIG_HEAD=$(git rev-parse --verify HEAD) &&
+       cd - &&
+       mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
+'
+
+test_expect_success 'create password-protected repository' '
+       mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb" &&
+       cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
+              "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git"
+'
+
+setup_askpass_helper
+
+test_expect_success 'clone remote repository' '
+       cd "$ROOT_PATH" &&
+       git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone
+'
+
+test_expect_success 'push to remote repository with packed refs' '
+       cd "$ROOT_PATH"/test_repo_clone &&
+       : >path2 &&
+       git add path2 &&
+       test_tick &&
+       git commit -m path2 &&
+       HEAD=$(git rev-parse --verify HEAD) &&
+       git push &&
+       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
+        test $HEAD = $(git rev-parse --verify HEAD))
+'
+
+test_expect_success 'push already up-to-date' '
+       git push
+'
+
+test_expect_success 'push to remote repository with unpacked refs' '
+       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
+        rm packed-refs &&
+        git update-ref refs/heads/master $ORIG_HEAD &&
+        git --bare update-server-info) &&
+       git push &&
+       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
+        test $HEAD = $(git rev-parse --verify HEAD))
+'
+
+test_expect_success 'http-push fetches unpacked objects' '
+       cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
+               "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_unpacked.git &&
+
+       git clone $HTTPD_URL/dumb/test_repo_unpacked.git \
+               "$ROOT_PATH"/fetch_unpacked &&
+
+       # By reset, we force git to retrieve the object
+       (cd "$ROOT_PATH"/fetch_unpacked &&
+        git reset --hard HEAD^ &&
+        git remote rm origin &&
+        git reflog expire --expire=0 --all &&
+        git prune &&
+        git push -f -v $HTTPD_URL/dumb/test_repo_unpacked.git master)
+'
+
+test_expect_success 'http-push fetches packed objects' '
+       cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
+               "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
+
+       git clone $HTTPD_URL/dumb/test_repo_packed.git \
+               "$ROOT_PATH"/test_repo_clone_packed &&
+
+       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
+        git --bare repack &&
+        git --bare prune-packed) &&
+
+       # By reset, we force git to retrieve the packed object
+       (cd "$ROOT_PATH"/test_repo_clone_packed &&
+        git reset --hard HEAD^ &&
+        git remote remove origin &&
+        git reflog expire --expire=0 --all &&
+        git prune &&
+        git push -f -v $HTTPD_URL/dumb/test_repo_packed.git master)
+'
+
+test_expect_success 'create and delete remote branch' '
+       cd "$ROOT_PATH"/test_repo_clone &&
+       git checkout -b dev &&
+       : >path3 &&
+       git add path3 &&
+       test_tick &&
+       git commit -m dev &&
+       git push origin dev &&
+       git push origin :dev &&
+       test_must_fail git show-ref --verify refs/remotes/origin/dev
+'
+
+test_expect_success 'MKCOL sends directory names with trailing slashes' '
+
+       ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
+
+'
+
+x1="[0-9a-f]"
+x2="$x1$x1"
+x5="$x1$x1$x1$x1$x1"
+x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
+x40="$x38$x2"
+
+test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
+       sed \
+               -e "s/PUT /OP /" \
+               -e "s/MOVE /OP /" \
+           -e "s|/objects/$x2/${x38}_$x40|WANTED_PATH_REQUEST|" \
+               "$HTTPD_ROOT_PATH"/access.log |
+       grep -e "\"OP .*WANTED_PATH_REQUEST HTTP/[.0-9]*\" 20[0-9] "
+
+'
+
+test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
+       "$ROOT_PATH"/test_repo_clone master
+
+test_expect_success 'push to password-protected repository (user in URL)' '
+       test_commit pw-user &&
+       set_askpass user@host pass@host &&
+       git push "$HTTPD_URL_USER/auth/dumb/test_repo.git" HEAD &&
+       git rev-parse --verify HEAD >expect &&
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
+               rev-parse --verify HEAD >actual &&
+       test_cmp expect actual
+'
+
+test_expect_failure 'user was prompted only once for password' '
+       expect_askpass pass user@host
+'
+
+test_expect_failure 'push to password-protected repository (no user in URL)' '
+       test_commit pw-nouser &&
+       set_askpass user@host pass@host &&
+       git push "$HTTPD_URL/auth/dumb/test_repo.git" HEAD &&
+       expect_askpass both user@host
+       git rev-parse --verify HEAD >expect &&
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
+               rev-parse --verify HEAD >actual &&
+       test_cmp expect actual
+'
+
+stop_httpd
+
+test_done
diff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh
deleted file mode 100755 (executable)
index 8d7b3c5..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
-#
-
-test_description='test WebDAV http-push
-
-This test runs various sanity checks on http-push.'
-
-. ./test-lib.sh
-
-if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
-then
-       skip_all="skipping test, USE_CURL_MULTI is not defined"
-       test_done
-fi
-
-LIB_HTTPD_DAV=t
-. "$TEST_DIRECTORY"/lib-httpd.sh
-ROOT_PATH="$PWD"
-start_httpd
-
-test_expect_success 'setup remote repository' '
-       cd "$ROOT_PATH" &&
-       mkdir test_repo &&
-       cd test_repo &&
-       git init &&
-       : >path1 &&
-       git add path1 &&
-       test_tick &&
-       git commit -m initial &&
-       cd - &&
-       git clone --bare test_repo test_repo.git &&
-       cd test_repo.git &&
-       git --bare update-server-info &&
-       mv hooks/post-update.sample hooks/post-update &&
-       ORIG_HEAD=$(git rev-parse --verify HEAD) &&
-       cd - &&
-       mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
-'
-
-test_expect_success 'create password-protected repository' '
-       mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb" &&
-       cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
-              "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git"
-'
-
-setup_askpass_helper
-
-test_expect_success 'clone remote repository' '
-       cd "$ROOT_PATH" &&
-       git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone
-'
-
-test_expect_success 'push to remote repository with packed refs' '
-       cd "$ROOT_PATH"/test_repo_clone &&
-       : >path2 &&
-       git add path2 &&
-       test_tick &&
-       git commit -m path2 &&
-       HEAD=$(git rev-parse --verify HEAD) &&
-       git push &&
-       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
-        test $HEAD = $(git rev-parse --verify HEAD))
-'
-
-test_expect_success 'push already up-to-date' '
-       git push
-'
-
-test_expect_success 'push to remote repository with unpacked refs' '
-       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
-        rm packed-refs &&
-        git update-ref refs/heads/master $ORIG_HEAD &&
-        git --bare update-server-info) &&
-       git push &&
-       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
-        test $HEAD = $(git rev-parse --verify HEAD))
-'
-
-test_expect_success 'http-push fetches unpacked objects' '
-       cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
-               "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_unpacked.git &&
-
-       git clone $HTTPD_URL/dumb/test_repo_unpacked.git \
-               "$ROOT_PATH"/fetch_unpacked &&
-
-       # By reset, we force git to retrieve the object
-       (cd "$ROOT_PATH"/fetch_unpacked &&
-        git reset --hard HEAD^ &&
-        git remote rm origin &&
-        git reflog expire --expire=0 --all &&
-        git prune &&
-        git push -f -v $HTTPD_URL/dumb/test_repo_unpacked.git master)
-'
-
-test_expect_success 'http-push fetches packed objects' '
-       cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
-               "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
-
-       git clone $HTTPD_URL/dumb/test_repo_packed.git \
-               "$ROOT_PATH"/test_repo_clone_packed &&
-
-       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
-        git --bare repack &&
-        git --bare prune-packed) &&
-
-       # By reset, we force git to retrieve the packed object
-       (cd "$ROOT_PATH"/test_repo_clone_packed &&
-        git reset --hard HEAD^ &&
-        git remote remove origin &&
-        git reflog expire --expire=0 --all &&
-        git prune &&
-        git push -f -v $HTTPD_URL/dumb/test_repo_packed.git master)
-'
-
-test_expect_success 'create and delete remote branch' '
-       cd "$ROOT_PATH"/test_repo_clone &&
-       git checkout -b dev &&
-       : >path3 &&
-       git add path3 &&
-       test_tick &&
-       git commit -m dev &&
-       git push origin dev &&
-       git push origin :dev &&
-       test_must_fail git show-ref --verify refs/remotes/origin/dev
-'
-
-test_expect_success 'MKCOL sends directory names with trailing slashes' '
-
-       ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
-
-'
-
-x1="[0-9a-f]"
-x2="$x1$x1"
-x5="$x1$x1$x1$x1$x1"
-x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
-x40="$x38$x2"
-
-test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
-       sed \
-               -e "s/PUT /OP /" \
-               -e "s/MOVE /OP /" \
-           -e "s|/objects/$x2/${x38}_$x40|WANTED_PATH_REQUEST|" \
-               "$HTTPD_ROOT_PATH"/access.log |
-       grep -e "\"OP .*WANTED_PATH_REQUEST HTTP/[.0-9]*\" 20[0-9] "
-
-'
-
-test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
-       "$ROOT_PATH"/test_repo_clone master
-
-test_expect_success 'push to password-protected repository (user in URL)' '
-       test_commit pw-user &&
-       set_askpass user@host pass@host &&
-       git push "$HTTPD_URL_USER/auth/dumb/test_repo.git" HEAD &&
-       git rev-parse --verify HEAD >expect &&
-       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
-               rev-parse --verify HEAD >actual &&
-       test_cmp expect actual
-'
-
-test_expect_failure 'user was prompted only once for password' '
-       expect_askpass pass user@host
-'
-
-test_expect_failure 'push to password-protected repository (no user in URL)' '
-       test_commit pw-nouser &&
-       set_askpass user@host pass@host &&
-       git push "$HTTPD_URL/auth/dumb/test_repo.git" HEAD &&
-       expect_askpass both user@host
-       git rev-parse --verify HEAD >expect &&
-       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
-               rev-parse --verify HEAD >actual &&
-       test_cmp expect actual
-'
-
-stop_httpd
-
-test_done
diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh
new file mode 100755 (executable)
index 0000000..73af16f
--- /dev/null
@@ -0,0 +1,327 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
+#
+
+test_description='test smart pushing over http via http-backend'
+. ./test-lib.sh
+
+if test -n "$NO_CURL"; then
+       skip_all='skipping test, git built without http support'
+       test_done
+fi
+
+ROOT_PATH="$PWD"
+. "$TEST_DIRECTORY"/lib-httpd.sh
+. "$TEST_DIRECTORY"/lib-terminal.sh
+start_httpd
+
+test_expect_success 'setup remote repository' '
+       cd "$ROOT_PATH" &&
+       mkdir test_repo &&
+       cd test_repo &&
+       git init &&
+       : >path1 &&
+       git add path1 &&
+       test_tick &&
+       git commit -m initial &&
+       cd - &&
+       git clone --bare test_repo test_repo.git &&
+       cd test_repo.git &&
+       git config http.receivepack true &&
+       git config core.logallrefupdates true &&
+       ORIG_HEAD=$(git rev-parse --verify HEAD) &&
+       cd - &&
+       mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
+'
+
+setup_askpass_helper
+
+cat >exp <<EOF
+GET  /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
+POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
+EOF
+test_expect_success 'no empty path components' '
+       # In the URL, add a trailing slash, and see if git appends yet another
+       # slash.
+       cd "$ROOT_PATH" &&
+       git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone &&
+
+       sed -e "
+               s/^.* \"//
+               s/\"//
+               s/ [1-9][0-9]*\$//
+               s/^GET /GET  /
+       " >act <"$HTTPD_ROOT_PATH"/access.log &&
+
+       # Clear the log, so that it does not affect the "used receive-pack
+       # service" test which reads the log too.
+       #
+       # We do this before the actual comparison to ensure the log is cleared.
+       echo > "$HTTPD_ROOT_PATH"/access.log &&
+
+       test_cmp exp act
+'
+
+test_expect_success 'clone remote repository' '
+       rm -rf test_repo_clone &&
+       git clone $HTTPD_URL/smart/test_repo.git test_repo_clone &&
+       (
+               cd test_repo_clone && git config push.default matching
+       )
+'
+
+test_expect_success 'push to remote repository (standard)' '
+       cd "$ROOT_PATH"/test_repo_clone &&
+       : >path2 &&
+       git add path2 &&
+       test_tick &&
+       git commit -m path2 &&
+       HEAD=$(git rev-parse --verify HEAD) &&
+       GIT_CURL_VERBOSE=1 git push -v -v 2>err &&
+       ! grep "Expect: 100-continue" err &&
+       grep "POST git-receive-pack ([0-9]* bytes)" err &&
+       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
+        test $HEAD = $(git rev-parse --verify HEAD))
+'
+
+test_expect_success 'push already up-to-date' '
+       git push
+'
+
+test_expect_success 'create and delete remote branch' '
+       cd "$ROOT_PATH"/test_repo_clone &&
+       git checkout -b dev &&
+       : >path3 &&
+       git add path3 &&
+       test_tick &&
+       git commit -m dev &&
+       git push origin dev &&
+       git push origin :dev &&
+       test_must_fail git show-ref --verify refs/remotes/origin/dev
+'
+
+cat >"$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" <<EOF
+#!/bin/sh
+exit 1
+EOF
+chmod a+x "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
+
+cat >exp <<EOF
+remote: error: hook declined to update refs/heads/dev2
+To http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git
+ ! [remote rejected] dev2 -> dev2 (hook declined)
+error: failed to push some refs to 'http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git'
+EOF
+
+test_expect_success 'rejected update prints status' '
+       cd "$ROOT_PATH"/test_repo_clone &&
+       git checkout -b dev2 &&
+       : >path4 &&
+       git add path4 &&
+       test_tick &&
+       git commit -m dev2 &&
+       test_must_fail git push origin dev2 2>act &&
+       sed -e "/^remote: /s/ *$//" <act >cmp &&
+       test_cmp exp cmp
+'
+rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
+
+cat >exp <<EOF
+
+GET  /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
+POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
+GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
+POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
+GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
+GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
+POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
+GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
+POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
+GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
+POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
+EOF
+test_expect_success 'used receive-pack service' '
+       sed -e "
+               s/^.* \"//
+               s/\"//
+               s/ [1-9][0-9]*\$//
+               s/^GET /GET  /
+       " >act <"$HTTPD_ROOT_PATH"/access.log &&
+       test_cmp exp act
+'
+
+test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
+       "$ROOT_PATH"/test_repo_clone master             success
+
+test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' '
+       # create a dissimilarly-named remote ref so that git is unable to match the
+       # two refs (viz. local, remote) unless an explicit refspec is provided.
+       git push origin master:retsam
+
+       echo "change changed" > path2 &&
+       git commit -a -m path2 --amend &&
+
+       # push master too; this ensures there is at least one '"'push'"' command to
+       # the remote helper and triggers interaction with the helper.
+       test_must_fail git push -v origin +master master:retsam >output 2>&1'
+
+test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: remote output' '
+       grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *master -> master (forced update)$" output &&
+       grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output
+'
+
+test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: our output' '
+       test_i18ngrep "Updates were rejected because" \
+               output
+'
+
+test_expect_success 'push (chunked)' '
+       git checkout master &&
+       test_commit commit path3 &&
+       HEAD=$(git rev-parse --verify HEAD) &&
+       test_config http.postbuffer 4 &&
+       git push -v -v origin $BRANCH 2>err &&
+       grep "POST git-receive-pack (chunked)" err &&
+       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
+        test $HEAD = $(git rev-parse --verify HEAD))
+'
+
+test_expect_success 'push --all can push to empty repo' '
+       d=$HTTPD_DOCUMENT_ROOT_PATH/empty-all.git &&
+       git init --bare "$d" &&
+       git --git-dir="$d" config http.receivepack true &&
+       git push --all "$HTTPD_URL"/smart/empty-all.git
+'
+
+test_expect_success 'push --mirror can push to empty repo' '
+       d=$HTTPD_DOCUMENT_ROOT_PATH/empty-mirror.git &&
+       git init --bare "$d" &&
+       git --git-dir="$d" config http.receivepack true &&
+       git push --mirror "$HTTPD_URL"/smart/empty-mirror.git
+'
+
+test_expect_success 'push --all to repo with alternates' '
+       s=$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git &&
+       d=$HTTPD_DOCUMENT_ROOT_PATH/alternates-all.git &&
+       git clone --bare --shared "$s" "$d" &&
+       git --git-dir="$d" config http.receivepack true &&
+       git --git-dir="$d" repack -adl &&
+       git push --all "$HTTPD_URL"/smart/alternates-all.git
+'
+
+test_expect_success 'push --mirror to repo with alternates' '
+       s=$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git &&
+       d=$HTTPD_DOCUMENT_ROOT_PATH/alternates-mirror.git &&
+       git clone --bare --shared "$s" "$d" &&
+       git --git-dir="$d" config http.receivepack true &&
+       git --git-dir="$d" repack -adl &&
+       git push --mirror "$HTTPD_URL"/smart/alternates-mirror.git
+'
+
+test_expect_success TTY 'push shows progress when stderr is a tty' '
+       cd "$ROOT_PATH"/test_repo_clone &&
+       test_commit noisy &&
+       test_terminal git push >output 2>&1 &&
+       grep "^Writing objects" output
+'
+
+test_expect_success TTY 'push --quiet silences status and progress' '
+       cd "$ROOT_PATH"/test_repo_clone &&
+       test_commit quiet &&
+       test_terminal git push --quiet >output 2>&1 &&
+       test_cmp /dev/null output
+'
+
+test_expect_success TTY 'push --no-progress silences progress but not status' '
+       cd "$ROOT_PATH"/test_repo_clone &&
+       test_commit no-progress &&
+       test_terminal git push --no-progress >output 2>&1 &&
+       grep "^To http" output &&
+       ! grep "^Writing objects"
+'
+
+test_expect_success 'push --progress shows progress to non-tty' '
+       cd "$ROOT_PATH"/test_repo_clone &&
+       test_commit progress &&
+       git push --progress >output 2>&1 &&
+       grep "^To http" output &&
+       grep "^Writing objects" output
+'
+
+test_expect_success 'http push gives sane defaults to reflog' '
+       cd "$ROOT_PATH"/test_repo_clone &&
+       test_commit reflog-test &&
+       git push "$HTTPD_URL"/smart/test_repo.git &&
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
+               log -g -1 --format="%gn <%ge>" >actual &&
+       echo "anonymous <anonymous@http.127.0.0.1>" >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success 'http push respects GIT_COMMITTER_* in reflog' '
+       cd "$ROOT_PATH"/test_repo_clone &&
+       test_commit custom-reflog-test &&
+       git push "$HTTPD_URL"/smart_custom_env/test_repo.git &&
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
+               log -g -1 --format="%gn <%ge>" >actual &&
+       echo "Custom User <custom@example.com>" >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success 'push over smart http with auth' '
+       cd "$ROOT_PATH/test_repo_clone" &&
+       echo push-auth-test >expect &&
+       test_commit push-auth-test &&
+       set_askpass user@host pass@host &&
+       git push "$HTTPD_URL"/auth/smart/test_repo.git &&
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
+               log -1 --format=%s >actual &&
+       expect_askpass both user@host &&
+       test_cmp expect actual
+'
+
+test_expect_success 'push to auth-only-for-push repo' '
+       cd "$ROOT_PATH/test_repo_clone" &&
+       echo push-half-auth >expect &&
+       test_commit push-half-auth &&
+       set_askpass user@host pass@host &&
+       git push "$HTTPD_URL"/auth-push/smart/test_repo.git &&
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
+               log -1 --format=%s >actual &&
+       expect_askpass both user@host &&
+       test_cmp expect actual
+'
+
+test_expect_success 'create repo without http.receivepack set' '
+       cd "$ROOT_PATH" &&
+       git init half-auth &&
+       (
+               cd half-auth &&
+               test_commit one
+       ) &&
+       git clone --bare half-auth "$HTTPD_DOCUMENT_ROOT_PATH/half-auth.git"
+'
+
+test_expect_success 'clone via half-auth-complete does not need password' '
+       cd "$ROOT_PATH" &&
+       set_askpass wrong &&
+       git clone "$HTTPD_URL"/half-auth-complete/smart/half-auth.git \
+               half-auth-clone &&
+       expect_askpass none
+'
+
+test_expect_success 'push into half-auth-complete requires password' '
+       cd "$ROOT_PATH/half-auth-clone" &&
+       echo two >expect &&
+       test_commit two &&
+       set_askpass user@host pass@host &&
+       git push "$HTTPD_URL/half-auth-complete/smart/half-auth.git" &&
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/half-auth.git" \
+               log -1 --format=%s >actual &&
+       expect_askpass both user@host &&
+       test_cmp expect actual
+'
+
+stop_httpd
+test_done
diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh
deleted file mode 100755 (executable)
index 73af16f..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
-#
-
-test_description='test smart pushing over http via http-backend'
-. ./test-lib.sh
-
-if test -n "$NO_CURL"; then
-       skip_all='skipping test, git built without http support'
-       test_done
-fi
-
-ROOT_PATH="$PWD"
-. "$TEST_DIRECTORY"/lib-httpd.sh
-. "$TEST_DIRECTORY"/lib-terminal.sh
-start_httpd
-
-test_expect_success 'setup remote repository' '
-       cd "$ROOT_PATH" &&
-       mkdir test_repo &&
-       cd test_repo &&
-       git init &&
-       : >path1 &&
-       git add path1 &&
-       test_tick &&
-       git commit -m initial &&
-       cd - &&
-       git clone --bare test_repo test_repo.git &&
-       cd test_repo.git &&
-       git config http.receivepack true &&
-       git config core.logallrefupdates true &&
-       ORIG_HEAD=$(git rev-parse --verify HEAD) &&
-       cd - &&
-       mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
-'
-
-setup_askpass_helper
-
-cat >exp <<EOF
-GET  /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
-POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
-EOF
-test_expect_success 'no empty path components' '
-       # In the URL, add a trailing slash, and see if git appends yet another
-       # slash.
-       cd "$ROOT_PATH" &&
-       git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone &&
-
-       sed -e "
-               s/^.* \"//
-               s/\"//
-               s/ [1-9][0-9]*\$//
-               s/^GET /GET  /
-       " >act <"$HTTPD_ROOT_PATH"/access.log &&
-
-       # Clear the log, so that it does not affect the "used receive-pack
-       # service" test which reads the log too.
-       #
-       # We do this before the actual comparison to ensure the log is cleared.
-       echo > "$HTTPD_ROOT_PATH"/access.log &&
-
-       test_cmp exp act
-'
-
-test_expect_success 'clone remote repository' '
-       rm -rf test_repo_clone &&
-       git clone $HTTPD_URL/smart/test_repo.git test_repo_clone &&
-       (
-               cd test_repo_clone && git config push.default matching
-       )
-'
-
-test_expect_success 'push to remote repository (standard)' '
-       cd "$ROOT_PATH"/test_repo_clone &&
-       : >path2 &&
-       git add path2 &&
-       test_tick &&
-       git commit -m path2 &&
-       HEAD=$(git rev-parse --verify HEAD) &&
-       GIT_CURL_VERBOSE=1 git push -v -v 2>err &&
-       ! grep "Expect: 100-continue" err &&
-       grep "POST git-receive-pack ([0-9]* bytes)" err &&
-       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
-        test $HEAD = $(git rev-parse --verify HEAD))
-'
-
-test_expect_success 'push already up-to-date' '
-       git push
-'
-
-test_expect_success 'create and delete remote branch' '
-       cd "$ROOT_PATH"/test_repo_clone &&
-       git checkout -b dev &&
-       : >path3 &&
-       git add path3 &&
-       test_tick &&
-       git commit -m dev &&
-       git push origin dev &&
-       git push origin :dev &&
-       test_must_fail git show-ref --verify refs/remotes/origin/dev
-'
-
-cat >"$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" <<EOF
-#!/bin/sh
-exit 1
-EOF
-chmod a+x "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
-
-cat >exp <<EOF
-remote: error: hook declined to update refs/heads/dev2
-To http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git
- ! [remote rejected] dev2 -> dev2 (hook declined)
-error: failed to push some refs to 'http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git'
-EOF
-
-test_expect_success 'rejected update prints status' '
-       cd "$ROOT_PATH"/test_repo_clone &&
-       git checkout -b dev2 &&
-       : >path4 &&
-       git add path4 &&
-       test_tick &&
-       git commit -m dev2 &&
-       test_must_fail git push origin dev2 2>act &&
-       sed -e "/^remote: /s/ *$//" <act >cmp &&
-       test_cmp exp cmp
-'
-rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
-
-cat >exp <<EOF
-
-GET  /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
-POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
-GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
-POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
-GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
-GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
-POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
-GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
-POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
-GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
-POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
-EOF
-test_expect_success 'used receive-pack service' '
-       sed -e "
-               s/^.* \"//
-               s/\"//
-               s/ [1-9][0-9]*\$//
-               s/^GET /GET  /
-       " >act <"$HTTPD_ROOT_PATH"/access.log &&
-       test_cmp exp act
-'
-
-test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
-       "$ROOT_PATH"/test_repo_clone master             success
-
-test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' '
-       # create a dissimilarly-named remote ref so that git is unable to match the
-       # two refs (viz. local, remote) unless an explicit refspec is provided.
-       git push origin master:retsam
-
-       echo "change changed" > path2 &&
-       git commit -a -m path2 --amend &&
-
-       # push master too; this ensures there is at least one '"'push'"' command to
-       # the remote helper and triggers interaction with the helper.
-       test_must_fail git push -v origin +master master:retsam >output 2>&1'
-
-test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: remote output' '
-       grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *master -> master (forced update)$" output &&
-       grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output
-'
-
-test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: our output' '
-       test_i18ngrep "Updates were rejected because" \
-               output
-'
-
-test_expect_success 'push (chunked)' '
-       git checkout master &&
-       test_commit commit path3 &&
-       HEAD=$(git rev-parse --verify HEAD) &&
-       test_config http.postbuffer 4 &&
-       git push -v -v origin $BRANCH 2>err &&
-       grep "POST git-receive-pack (chunked)" err &&
-       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
-        test $HEAD = $(git rev-parse --verify HEAD))
-'
-
-test_expect_success 'push --all can push to empty repo' '
-       d=$HTTPD_DOCUMENT_ROOT_PATH/empty-all.git &&
-       git init --bare "$d" &&
-       git --git-dir="$d" config http.receivepack true &&
-       git push --all "$HTTPD_URL"/smart/empty-all.git
-'
-
-test_expect_success 'push --mirror can push to empty repo' '
-       d=$HTTPD_DOCUMENT_ROOT_PATH/empty-mirror.git &&
-       git init --bare "$d" &&
-       git --git-dir="$d" config http.receivepack true &&
-       git push --mirror "$HTTPD_URL"/smart/empty-mirror.git
-'
-
-test_expect_success 'push --all to repo with alternates' '
-       s=$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git &&
-       d=$HTTPD_DOCUMENT_ROOT_PATH/alternates-all.git &&
-       git clone --bare --shared "$s" "$d" &&
-       git --git-dir="$d" config http.receivepack true &&
-       git --git-dir="$d" repack -adl &&
-       git push --all "$HTTPD_URL"/smart/alternates-all.git
-'
-
-test_expect_success 'push --mirror to repo with alternates' '
-       s=$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git &&
-       d=$HTTPD_DOCUMENT_ROOT_PATH/alternates-mirror.git &&
-       git clone --bare --shared "$s" "$d" &&
-       git --git-dir="$d" config http.receivepack true &&
-       git --git-dir="$d" repack -adl &&
-       git push --mirror "$HTTPD_URL"/smart/alternates-mirror.git
-'
-
-test_expect_success TTY 'push shows progress when stderr is a tty' '
-       cd "$ROOT_PATH"/test_repo_clone &&
-       test_commit noisy &&
-       test_terminal git push >output 2>&1 &&
-       grep "^Writing objects" output
-'
-
-test_expect_success TTY 'push --quiet silences status and progress' '
-       cd "$ROOT_PATH"/test_repo_clone &&
-       test_commit quiet &&
-       test_terminal git push --quiet >output 2>&1 &&
-       test_cmp /dev/null output
-'
-
-test_expect_success TTY 'push --no-progress silences progress but not status' '
-       cd "$ROOT_PATH"/test_repo_clone &&
-       test_commit no-progress &&
-       test_terminal git push --no-progress >output 2>&1 &&
-       grep "^To http" output &&
-       ! grep "^Writing objects"
-'
-
-test_expect_success 'push --progress shows progress to non-tty' '
-       cd "$ROOT_PATH"/test_repo_clone &&
-       test_commit progress &&
-       git push --progress >output 2>&1 &&
-       grep "^To http" output &&
-       grep "^Writing objects" output
-'
-
-test_expect_success 'http push gives sane defaults to reflog' '
-       cd "$ROOT_PATH"/test_repo_clone &&
-       test_commit reflog-test &&
-       git push "$HTTPD_URL"/smart/test_repo.git &&
-       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
-               log -g -1 --format="%gn <%ge>" >actual &&
-       echo "anonymous <anonymous@http.127.0.0.1>" >expect &&
-       test_cmp expect actual
-'
-
-test_expect_success 'http push respects GIT_COMMITTER_* in reflog' '
-       cd "$ROOT_PATH"/test_repo_clone &&
-       test_commit custom-reflog-test &&
-       git push "$HTTPD_URL"/smart_custom_env/test_repo.git &&
-       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
-               log -g -1 --format="%gn <%ge>" >actual &&
-       echo "Custom User <custom@example.com>" >expect &&
-       test_cmp expect actual
-'
-
-test_expect_success 'push over smart http with auth' '
-       cd "$ROOT_PATH/test_repo_clone" &&
-       echo push-auth-test >expect &&
-       test_commit push-auth-test &&
-       set_askpass user@host pass@host &&
-       git push "$HTTPD_URL"/auth/smart/test_repo.git &&
-       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
-               log -1 --format=%s >actual &&
-       expect_askpass both user@host &&
-       test_cmp expect actual
-'
-
-test_expect_success 'push to auth-only-for-push repo' '
-       cd "$ROOT_PATH/test_repo_clone" &&
-       echo push-half-auth >expect &&
-       test_commit push-half-auth &&
-       set_askpass user@host pass@host &&
-       git push "$HTTPD_URL"/auth-push/smart/test_repo.git &&
-       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
-               log -1 --format=%s >actual &&
-       expect_askpass both user@host &&
-       test_cmp expect actual
-'
-
-test_expect_success 'create repo without http.receivepack set' '
-       cd "$ROOT_PATH" &&
-       git init half-auth &&
-       (
-               cd half-auth &&
-               test_commit one
-       ) &&
-       git clone --bare half-auth "$HTTPD_DOCUMENT_ROOT_PATH/half-auth.git"
-'
-
-test_expect_success 'clone via half-auth-complete does not need password' '
-       cd "$ROOT_PATH" &&
-       set_askpass wrong &&
-       git clone "$HTTPD_URL"/half-auth-complete/smart/half-auth.git \
-               half-auth-clone &&
-       expect_askpass none
-'
-
-test_expect_success 'push into half-auth-complete requires password' '
-       cd "$ROOT_PATH/half-auth-clone" &&
-       echo two >expect &&
-       test_commit two &&
-       set_askpass user@host pass@host &&
-       git push "$HTTPD_URL/half-auth-complete/smart/half-auth.git" &&
-       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/half-auth.git" \
-               log -1 --format=%s >actual &&
-       expect_askpass both user@host &&
-       test_cmp expect actual
-'
-
-stop_httpd
-test_done
diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
new file mode 100755 (executable)
index 0000000..1a3a2b6
--- /dev/null
@@ -0,0 +1,175 @@
+#!/bin/sh
+
+test_description='test dumb fetching over http via static file'
+. ./test-lib.sh
+
+if test -n "$NO_CURL"; then
+       skip_all='skipping test, git built without http support'
+       test_done
+fi
+
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+test_expect_success 'setup repository' '
+       git config push.default matching &&
+       echo content1 >file &&
+       git add file &&
+       git commit -m one
+       echo content2 >file &&
+       git add file &&
+       git commit -m two
+'
+
+test_expect_success 'create http-accessible bare repository with loose objects' '
+       cp -R .git "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+       (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+        git config core.bare true &&
+        mkdir -p hooks &&
+        echo "exec git update-server-info" >hooks/post-update &&
+        chmod +x hooks/post-update &&
+        hooks/post-update
+       ) &&
+       git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+       git push public master:master
+'
+
+test_expect_success 'clone http repository' '
+       git clone $HTTPD_URL/dumb/repo.git clone-tmpl &&
+       cp -R clone-tmpl clone &&
+       test_cmp file clone/file
+'
+
+test_expect_success 'create password-protected repository' '
+       mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/" &&
+       cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
+              "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/repo.git"
+'
+
+setup_askpass_helper
+
+test_expect_success 'cloning password-protected repository can fail' '
+       set_askpass wrong &&
+       test_must_fail git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-fail &&
+       expect_askpass both wrong
+'
+
+test_expect_success 'http auth can use user/pass in URL' '
+       set_askpass wrong &&
+       git clone "$HTTPD_URL_USER_PASS/auth/dumb/repo.git" clone-auth-none &&
+       expect_askpass none
+'
+
+test_expect_success 'http auth can use just user in URL' '
+       set_askpass wrong pass@host &&
+       git clone "$HTTPD_URL_USER/auth/dumb/repo.git" clone-auth-pass &&
+       expect_askpass pass user@host
+'
+
+test_expect_success 'http auth can request both user and pass' '
+       set_askpass user@host pass@host &&
+       git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-both &&
+       expect_askpass both user@host
+'
+
+test_expect_success 'http auth respects credential helper config' '
+       test_config_global credential.helper "!f() {
+               cat >/dev/null
+               echo username=user@host
+               echo password=pass@host
+       }; f" &&
+       set_askpass wrong &&
+       git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-helper &&
+       expect_askpass none
+'
+
+test_expect_success 'http auth can get username from config' '
+       test_config_global "credential.$HTTPD_URL.username" user@host &&
+       set_askpass wrong pass@host &&
+       git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-user &&
+       expect_askpass pass user@host
+'
+
+test_expect_success 'configured username does not override URL' '
+       test_config_global "credential.$HTTPD_URL.username" wrong &&
+       set_askpass wrong pass@host &&
+       git clone "$HTTPD_URL_USER/auth/dumb/repo.git" clone-auth-user2 &&
+       expect_askpass pass user@host
+'
+
+test_expect_success 'fetch changes via http' '
+       echo content >>file &&
+       git commit -a -m two &&
+       git push public &&
+       (cd clone && git pull) &&
+       test_cmp file clone/file
+'
+
+test_expect_success 'fetch changes via manual http-fetch' '
+       cp -R clone-tmpl clone2 &&
+
+       HEAD=$(git rev-parse --verify HEAD) &&
+       (cd clone2 &&
+        git http-fetch -a -w heads/master-new $HEAD $(git config remote.origin.url) &&
+        git checkout master-new &&
+        test $HEAD = $(git rev-parse --verify HEAD)) &&
+       test_cmp file clone2/file
+'
+
+test_expect_success 'http remote detects correct HEAD' '
+       git push public master:other &&
+       (cd clone &&
+        git remote set-head origin -d &&
+        git remote set-head origin -a &&
+        git symbolic-ref refs/remotes/origin/HEAD > output &&
+        echo refs/remotes/origin/master > expect &&
+        test_cmp expect output
+       )
+'
+
+test_expect_success 'fetch packed objects' '
+       cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
+       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
+        git --bare repack -a -d
+       ) &&
+       git clone $HTTPD_URL/dumb/repo_pack.git
+'
+
+test_expect_success 'fetch notices corrupt pack' '
+       cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
+       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
+        p=`ls objects/pack/pack-*.pack` &&
+        chmod u+w $p &&
+        printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
+       ) &&
+       mkdir repo_bad1.git &&
+       (cd repo_bad1.git &&
+        git --bare init &&
+        test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad1.git &&
+        test 0 = `ls objects/pack/pack-*.pack | wc -l`
+       )
+'
+
+test_expect_success 'fetch notices corrupt idx' '
+       cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
+       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
+        p=`ls objects/pack/pack-*.idx` &&
+        chmod u+w $p &&
+        printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
+       ) &&
+       mkdir repo_bad2.git &&
+       (cd repo_bad2.git &&
+        git --bare init &&
+        test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad2.git &&
+        test 0 = `ls objects/pack | wc -l`
+       )
+'
+
+test_expect_success 'did not use upload-pack service' '
+       grep '/git-upload-pack' <"$HTTPD_ROOT_PATH"/access.log >act
+       : >exp
+       test_cmp exp act
+'
+
+stop_httpd
+test_done
diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh
deleted file mode 100755 (executable)
index 1a3a2b6..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-#!/bin/sh
-
-test_description='test dumb fetching over http via static file'
-. ./test-lib.sh
-
-if test -n "$NO_CURL"; then
-       skip_all='skipping test, git built without http support'
-       test_done
-fi
-
-. "$TEST_DIRECTORY"/lib-httpd.sh
-start_httpd
-
-test_expect_success 'setup repository' '
-       git config push.default matching &&
-       echo content1 >file &&
-       git add file &&
-       git commit -m one
-       echo content2 >file &&
-       git add file &&
-       git commit -m two
-'
-
-test_expect_success 'create http-accessible bare repository with loose objects' '
-       cp -R .git "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
-       (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
-        git config core.bare true &&
-        mkdir -p hooks &&
-        echo "exec git update-server-info" >hooks/post-update &&
-        chmod +x hooks/post-update &&
-        hooks/post-update
-       ) &&
-       git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
-       git push public master:master
-'
-
-test_expect_success 'clone http repository' '
-       git clone $HTTPD_URL/dumb/repo.git clone-tmpl &&
-       cp -R clone-tmpl clone &&
-       test_cmp file clone/file
-'
-
-test_expect_success 'create password-protected repository' '
-       mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/" &&
-       cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
-              "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/repo.git"
-'
-
-setup_askpass_helper
-
-test_expect_success 'cloning password-protected repository can fail' '
-       set_askpass wrong &&
-       test_must_fail git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-fail &&
-       expect_askpass both wrong
-'
-
-test_expect_success 'http auth can use user/pass in URL' '
-       set_askpass wrong &&
-       git clone "$HTTPD_URL_USER_PASS/auth/dumb/repo.git" clone-auth-none &&
-       expect_askpass none
-'
-
-test_expect_success 'http auth can use just user in URL' '
-       set_askpass wrong pass@host &&
-       git clone "$HTTPD_URL_USER/auth/dumb/repo.git" clone-auth-pass &&
-       expect_askpass pass user@host
-'
-
-test_expect_success 'http auth can request both user and pass' '
-       set_askpass user@host pass@host &&
-       git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-both &&
-       expect_askpass both user@host
-'
-
-test_expect_success 'http auth respects credential helper config' '
-       test_config_global credential.helper "!f() {
-               cat >/dev/null
-               echo username=user@host
-               echo password=pass@host
-       }; f" &&
-       set_askpass wrong &&
-       git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-helper &&
-       expect_askpass none
-'
-
-test_expect_success 'http auth can get username from config' '
-       test_config_global "credential.$HTTPD_URL.username" user@host &&
-       set_askpass wrong pass@host &&
-       git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-user &&
-       expect_askpass pass user@host
-'
-
-test_expect_success 'configured username does not override URL' '
-       test_config_global "credential.$HTTPD_URL.username" wrong &&
-       set_askpass wrong pass@host &&
-       git clone "$HTTPD_URL_USER/auth/dumb/repo.git" clone-auth-user2 &&
-       expect_askpass pass user@host
-'
-
-test_expect_success 'fetch changes via http' '
-       echo content >>file &&
-       git commit -a -m two &&
-       git push public &&
-       (cd clone && git pull) &&
-       test_cmp file clone/file
-'
-
-test_expect_success 'fetch changes via manual http-fetch' '
-       cp -R clone-tmpl clone2 &&
-
-       HEAD=$(git rev-parse --verify HEAD) &&
-       (cd clone2 &&
-        git http-fetch -a -w heads/master-new $HEAD $(git config remote.origin.url) &&
-        git checkout master-new &&
-        test $HEAD = $(git rev-parse --verify HEAD)) &&
-       test_cmp file clone2/file
-'
-
-test_expect_success 'http remote detects correct HEAD' '
-       git push public master:other &&
-       (cd clone &&
-        git remote set-head origin -d &&
-        git remote set-head origin -a &&
-        git symbolic-ref refs/remotes/origin/HEAD > output &&
-        echo refs/remotes/origin/master > expect &&
-        test_cmp expect output
-       )
-'
-
-test_expect_success 'fetch packed objects' '
-       cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
-       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
-        git --bare repack -a -d
-       ) &&
-       git clone $HTTPD_URL/dumb/repo_pack.git
-'
-
-test_expect_success 'fetch notices corrupt pack' '
-       cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
-       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
-        p=`ls objects/pack/pack-*.pack` &&
-        chmod u+w $p &&
-        printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
-       ) &&
-       mkdir repo_bad1.git &&
-       (cd repo_bad1.git &&
-        git --bare init &&
-        test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad1.git &&
-        test 0 = `ls objects/pack/pack-*.pack | wc -l`
-       )
-'
-
-test_expect_success 'fetch notices corrupt idx' '
-       cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
-       (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
-        p=`ls objects/pack/pack-*.idx` &&
-        chmod u+w $p &&
-        printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
-       ) &&
-       mkdir repo_bad2.git &&
-       (cd repo_bad2.git &&
-        git --bare init &&
-        test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad2.git &&
-        test 0 = `ls objects/pack | wc -l`
-       )
-'
-
-test_expect_success 'did not use upload-pack service' '
-       grep '/git-upload-pack' <"$HTTPD_ROOT_PATH"/access.log >act
-       : >exp
-       test_cmp exp act
-'
-
-stop_httpd
-test_done
diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh
new file mode 100755 (executable)
index 0000000..e07eaf3
--- /dev/null
@@ -0,0 +1,252 @@
+#!/bin/sh
+
+test_description='test smart fetching over http via http-backend'
+. ./test-lib.sh
+
+if test -n "$NO_CURL"; then
+       skip_all='skipping test, git built without http support'
+       test_done
+fi
+
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+test_expect_success 'setup repository' '
+       git config push.default matching &&
+       echo content >file &&
+       git add file &&
+       git commit -m one
+'
+
+test_expect_success 'create http-accessible bare repository' '
+       mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+       (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+        git --bare init
+       ) &&
+       git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+       git push public master:master
+'
+
+setup_askpass_helper
+
+cat >exp <<EOF
+> GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1
+> Accept: */*
+> Accept-Encoding: gzip
+> Pragma: no-cache
+< HTTP/1.1 200 OK
+< Pragma: no-cache
+< Cache-Control: no-cache, max-age=0, must-revalidate
+< Content-Type: application/x-git-upload-pack-advertisement
+> POST /smart/repo.git/git-upload-pack HTTP/1.1
+> Accept-Encoding: gzip
+> Content-Type: application/x-git-upload-pack-request
+> Accept: application/x-git-upload-pack-result
+> Content-Length: xxx
+< HTTP/1.1 200 OK
+< Pragma: no-cache
+< Cache-Control: no-cache, max-age=0, must-revalidate
+< Content-Type: application/x-git-upload-pack-result
+EOF
+test_expect_success 'clone http repository' '
+       GIT_CURL_VERBOSE=1 git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
+       test_cmp file clone/file &&
+       tr '\''\015'\'' Q <err |
+       sed -e "
+               s/Q\$//
+               /^[*] /d
+               /^$/d
+               /^< $/d
+
+               /^[^><]/{
+                       s/^/> /
+               }
+
+               /^> User-Agent: /d
+               /^> Host: /d
+               /^> POST /,$ {
+                       /^> Accept: [*]\\/[*]/d
+               }
+               s/^> Content-Length: .*/> Content-Length: xxx/
+               /^> 00..want /d
+               /^> 00.*done/d
+
+               /^< Server: /d
+               /^< Expires: /d
+               /^< Date: /d
+               /^< Content-Length: /d
+               /^< Transfer-Encoding: /d
+       " >act &&
+       test_cmp exp act
+'
+
+test_expect_success 'fetch changes via http' '
+       echo content >>file &&
+       git commit -a -m two &&
+       git push public
+       (cd clone && git pull) &&
+       test_cmp file clone/file
+'
+
+cat >exp <<EOF
+GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
+POST /smart/repo.git/git-upload-pack HTTP/1.1 200
+GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
+POST /smart/repo.git/git-upload-pack HTTP/1.1 200
+EOF
+test_expect_success 'used upload-pack service' '
+       sed -e "
+               s/^.* \"//
+               s/\"//
+               s/ [1-9][0-9]*\$//
+               s/^GET /GET  /
+       " >act <"$HTTPD_ROOT_PATH"/access.log &&
+       test_cmp exp act
+'
+
+test_expect_success 'follow redirects (301)' '
+       git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
+'
+
+test_expect_success 'follow redirects (302)' '
+       git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t
+'
+
+test_expect_success 'redirects re-root further requests' '
+       git clone $HTTPD_URL/smart-redir-limited/repo.git repo-redir-limited
+'
+
+test_expect_success 'clone from password-protected repository' '
+       echo two >expect &&
+       set_askpass user@host pass@host &&
+       git clone --bare "$HTTPD_URL/auth/smart/repo.git" smart-auth &&
+       expect_askpass both user@host &&
+       git --git-dir=smart-auth log -1 --format=%s >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'clone from auth-only-for-push repository' '
+       echo two >expect &&
+       set_askpass wrong &&
+       git clone --bare "$HTTPD_URL/auth-push/smart/repo.git" smart-noauth &&
+       expect_askpass none &&
+       git --git-dir=smart-noauth log -1 --format=%s >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'clone from auth-only-for-objects repository' '
+       echo two >expect &&
+       set_askpass user@host pass@host &&
+       git clone --bare "$HTTPD_URL/auth-fetch/smart/repo.git" half-auth &&
+       expect_askpass both user@host &&
+       git --git-dir=half-auth log -1 --format=%s >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'no-op half-auth fetch does not require a password' '
+       set_askpass wrong &&
+       git --git-dir=half-auth fetch &&
+       expect_askpass none
+'
+
+test_expect_success 'redirects send auth to new location' '
+       set_askpass user@host pass@host &&
+       git -c credential.useHttpPath=true \
+         clone $HTTPD_URL/smart-redir-auth/repo.git repo-redir-auth &&
+       expect_askpass both user@host auth/smart/repo.git
+'
+
+test_expect_success 'disable dumb http on server' '
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
+               config http.getanyfile false
+'
+
+test_expect_success 'GIT_SMART_HTTP can disable smart http' '
+       (GIT_SMART_HTTP=0 &&
+        export GIT_SMART_HTTP &&
+        cd clone &&
+        test_must_fail git fetch)
+'
+
+test_expect_success 'invalid Content-Type rejected' '
+       test_must_fail git clone $HTTPD_URL/broken_smart/repo.git 2>actual
+       grep "not valid:" actual
+'
+
+test_expect_success 'create namespaced refs' '
+       test_commit namespaced &&
+       git push public HEAD:refs/namespaces/ns/refs/heads/master &&
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
+               symbolic-ref refs/namespaces/ns/HEAD refs/namespaces/ns/refs/heads/master
+'
+
+test_expect_success 'smart clone respects namespace' '
+       git clone "$HTTPD_URL/smart_namespace/repo.git" ns-smart &&
+       echo namespaced >expect &&
+       git --git-dir=ns-smart/.git log -1 --format=%s >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'dumb clone via http-backend respects namespace' '
+       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
+               config http.getanyfile true &&
+       GIT_SMART_HTTP=0 git clone \
+               "$HTTPD_URL/smart_namespace/repo.git" ns-dumb &&
+       echo namespaced >expect &&
+       git --git-dir=ns-dumb/.git log -1 --format=%s >actual &&
+       test_cmp expect actual
+'
+
+cat >cookies.txt <<EOF
+127.0.0.1      FALSE   /smart_cookies/ FALSE   0       othername       othervalue
+EOF
+cat >expect_cookies.txt <<EOF
+
+127.0.0.1      FALSE   /smart_cookies/ FALSE   0       othername       othervalue
+127.0.0.1      FALSE   /smart_cookies/repo.git/info/   FALSE   0       name    value
+EOF
+test_expect_success 'cookies stored in http.cookiefile when http.savecookies set' '
+       git config http.cookiefile cookies.txt &&
+       git config http.savecookies true &&
+       git ls-remote $HTTPD_URL/smart_cookies/repo.git master &&
+       tail -3 cookies.txt > cookies_tail.txt
+       test_cmp expect_cookies.txt cookies_tail.txt
+'
+
+test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
+
+test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
+       (
+       cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
+       for i in `test_seq 50000`
+       do
+               echo "commit refs/heads/too-many-refs"
+               echo "mark :$i"
+               echo "committer git <git@example.com> $i +0000"
+               echo "data 0"
+               echo "M 644 inline bla.txt"
+               echo "data 4"
+               echo "bla"
+               # make every commit dangling by always
+               # rewinding the branch after each commit
+               echo "reset refs/heads/too-many-refs"
+               echo "from :1"
+       done | git fast-import --export-marks=marks &&
+
+       # now assign tags to all the dangling commits we created above
+       tag=$(perl -e "print \"bla\" x 30") &&
+       sed -e "s|^:\([^ ]*\) \(.*\)$|\2 refs/tags/$tag-\1|" <marks >>packed-refs
+       )
+'
+
+test_expect_success EXPENSIVE 'clone the 50,000 tag repo to check OS command line overflow' '
+       git clone $HTTPD_URL/smart/repo.git too-many-refs 2>err &&
+       test_line_count = 0 err &&
+       (
+               cd too-many-refs &&
+               test $(git for-each-ref refs/tags | wc -l) = 50000
+       )
+'
+
+stop_httpd
+test_done
diff --git a/t/t5551-http-fetch.sh b/t/t5551-http-fetch.sh
deleted file mode 100755 (executable)
index e07eaf3..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-#!/bin/sh
-
-test_description='test smart fetching over http via http-backend'
-. ./test-lib.sh
-
-if test -n "$NO_CURL"; then
-       skip_all='skipping test, git built without http support'
-       test_done
-fi
-
-. "$TEST_DIRECTORY"/lib-httpd.sh
-start_httpd
-
-test_expect_success 'setup repository' '
-       git config push.default matching &&
-       echo content >file &&
-       git add file &&
-       git commit -m one
-'
-
-test_expect_success 'create http-accessible bare repository' '
-       mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
-       (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
-        git --bare init
-       ) &&
-       git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
-       git push public master:master
-'
-
-setup_askpass_helper
-
-cat >exp <<EOF
-> GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1
-> Accept: */*
-> Accept-Encoding: gzip
-> Pragma: no-cache
-< HTTP/1.1 200 OK
-< Pragma: no-cache
-< Cache-Control: no-cache, max-age=0, must-revalidate
-< Content-Type: application/x-git-upload-pack-advertisement
-> POST /smart/repo.git/git-upload-pack HTTP/1.1
-> Accept-Encoding: gzip
-> Content-Type: application/x-git-upload-pack-request
-> Accept: application/x-git-upload-pack-result
-> Content-Length: xxx
-< HTTP/1.1 200 OK
-< Pragma: no-cache
-< Cache-Control: no-cache, max-age=0, must-revalidate
-< Content-Type: application/x-git-upload-pack-result
-EOF
-test_expect_success 'clone http repository' '
-       GIT_CURL_VERBOSE=1 git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
-       test_cmp file clone/file &&
-       tr '\''\015'\'' Q <err |
-       sed -e "
-               s/Q\$//
-               /^[*] /d
-               /^$/d
-               /^< $/d
-
-               /^[^><]/{
-                       s/^/> /
-               }
-
-               /^> User-Agent: /d
-               /^> Host: /d
-               /^> POST /,$ {
-                       /^> Accept: [*]\\/[*]/d
-               }
-               s/^> Content-Length: .*/> Content-Length: xxx/
-               /^> 00..want /d
-               /^> 00.*done/d
-
-               /^< Server: /d
-               /^< Expires: /d
-               /^< Date: /d
-               /^< Content-Length: /d
-               /^< Transfer-Encoding: /d
-       " >act &&
-       test_cmp exp act
-'
-
-test_expect_success 'fetch changes via http' '
-       echo content >>file &&
-       git commit -a -m two &&
-       git push public
-       (cd clone && git pull) &&
-       test_cmp file clone/file
-'
-
-cat >exp <<EOF
-GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
-POST /smart/repo.git/git-upload-pack HTTP/1.1 200
-GET  /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
-POST /smart/repo.git/git-upload-pack HTTP/1.1 200
-EOF
-test_expect_success 'used upload-pack service' '
-       sed -e "
-               s/^.* \"//
-               s/\"//
-               s/ [1-9][0-9]*\$//
-               s/^GET /GET  /
-       " >act <"$HTTPD_ROOT_PATH"/access.log &&
-       test_cmp exp act
-'
-
-test_expect_success 'follow redirects (301)' '
-       git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
-'
-
-test_expect_success 'follow redirects (302)' '
-       git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t
-'
-
-test_expect_success 'redirects re-root further requests' '
-       git clone $HTTPD_URL/smart-redir-limited/repo.git repo-redir-limited
-'
-
-test_expect_success 'clone from password-protected repository' '
-       echo two >expect &&
-       set_askpass user@host pass@host &&
-       git clone --bare "$HTTPD_URL/auth/smart/repo.git" smart-auth &&
-       expect_askpass both user@host &&
-       git --git-dir=smart-auth log -1 --format=%s >actual &&
-       test_cmp expect actual
-'
-
-test_expect_success 'clone from auth-only-for-push repository' '
-       echo two >expect &&
-       set_askpass wrong &&
-       git clone --bare "$HTTPD_URL/auth-push/smart/repo.git" smart-noauth &&
-       expect_askpass none &&
-       git --git-dir=smart-noauth log -1 --format=%s >actual &&
-       test_cmp expect actual
-'
-
-test_expect_success 'clone from auth-only-for-objects repository' '
-       echo two >expect &&
-       set_askpass user@host pass@host &&
-       git clone --bare "$HTTPD_URL/auth-fetch/smart/repo.git" half-auth &&
-       expect_askpass both user@host &&
-       git --git-dir=half-auth log -1 --format=%s >actual &&
-       test_cmp expect actual
-'
-
-test_expect_success 'no-op half-auth fetch does not require a password' '
-       set_askpass wrong &&
-       git --git-dir=half-auth fetch &&
-       expect_askpass none
-'
-
-test_expect_success 'redirects send auth to new location' '
-       set_askpass user@host pass@host &&
-       git -c credential.useHttpPath=true \
-         clone $HTTPD_URL/smart-redir-auth/repo.git repo-redir-auth &&
-       expect_askpass both user@host auth/smart/repo.git
-'
-
-test_expect_success 'disable dumb http on server' '
-       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
-               config http.getanyfile false
-'
-
-test_expect_success 'GIT_SMART_HTTP can disable smart http' '
-       (GIT_SMART_HTTP=0 &&
-        export GIT_SMART_HTTP &&
-        cd clone &&
-        test_must_fail git fetch)
-'
-
-test_expect_success 'invalid Content-Type rejected' '
-       test_must_fail git clone $HTTPD_URL/broken_smart/repo.git 2>actual
-       grep "not valid:" actual
-'
-
-test_expect_success 'create namespaced refs' '
-       test_commit namespaced &&
-       git push public HEAD:refs/namespaces/ns/refs/heads/master &&
-       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
-               symbolic-ref refs/namespaces/ns/HEAD refs/namespaces/ns/refs/heads/master
-'
-
-test_expect_success 'smart clone respects namespace' '
-       git clone "$HTTPD_URL/smart_namespace/repo.git" ns-smart &&
-       echo namespaced >expect &&
-       git --git-dir=ns-smart/.git log -1 --format=%s >actual &&
-       test_cmp expect actual
-'
-
-test_expect_success 'dumb clone via http-backend respects namespace' '
-       git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
-               config http.getanyfile true &&
-       GIT_SMART_HTTP=0 git clone \
-               "$HTTPD_URL/smart_namespace/repo.git" ns-dumb &&
-       echo namespaced >expect &&
-       git --git-dir=ns-dumb/.git log -1 --format=%s >actual &&
-       test_cmp expect actual
-'
-
-cat >cookies.txt <<EOF
-127.0.0.1      FALSE   /smart_cookies/ FALSE   0       othername       othervalue
-EOF
-cat >expect_cookies.txt <<EOF
-
-127.0.0.1      FALSE   /smart_cookies/ FALSE   0       othername       othervalue
-127.0.0.1      FALSE   /smart_cookies/repo.git/info/   FALSE   0       name    value
-EOF
-test_expect_success 'cookies stored in http.cookiefile when http.savecookies set' '
-       git config http.cookiefile cookies.txt &&
-       git config http.savecookies true &&
-       git ls-remote $HTTPD_URL/smart_cookies/repo.git master &&
-       tail -3 cookies.txt > cookies_tail.txt
-       test_cmp expect_cookies.txt cookies_tail.txt
-'
-
-test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
-
-test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
-       (
-       cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
-       for i in `test_seq 50000`
-       do
-               echo "commit refs/heads/too-many-refs"
-               echo "mark :$i"
-               echo "committer git <git@example.com> $i +0000"
-               echo "data 0"
-               echo "M 644 inline bla.txt"
-               echo "data 4"
-               echo "bla"
-               # make every commit dangling by always
-               # rewinding the branch after each commit
-               echo "reset refs/heads/too-many-refs"
-               echo "from :1"
-       done | git fast-import --export-marks=marks &&
-
-       # now assign tags to all the dangling commits we created above
-       tag=$(perl -e "print \"bla\" x 30") &&
-       sed -e "s|^:\([^ ]*\) \(.*\)$|\2 refs/tags/$tag-\1|" <marks >>packed-refs
-       )
-'
-
-test_expect_success EXPENSIVE 'clone the 50,000 tag repo to check OS command line overflow' '
-       git clone $HTTPD_URL/smart/repo.git too-many-refs 2>err &&
-       test_line_count = 0 err &&
-       (
-               cd too-many-refs &&
-               test $(git for-each-ref refs/tags | wc -l) = 50000
-       )
-'
-
-stop_httpd
-test_done