From a87679339c0abb67b0be8b8b1cc10483f28df038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 6 Feb 2014 22:10:34 +0700 Subject: test: rename http fetch and push test files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make clear which one is for dumb protocol, which one is for smart from their file name. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano diff --git a/t/t5540-http-push-webdav.sh b/t/t5540-http-push-webdav.sh new file mode 100755 index 0000000..8d7b3c5 --- /dev/null +++ b/t/t5540-http-push-webdav.sh @@ -0,0 +1,181 @@ +#!/bin/sh +# +# Copyright (c) 2008 Clemens Buchacher +# + +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 index 8d7b3c5..0000000 --- a/t/t5540-http-push.sh +++ /dev/null @@ -1,181 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2008 Clemens Buchacher -# - -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 index 0000000..73af16f --- /dev/null +++ b/t/t5541-http-push-smart.sh @@ -0,0 +1,327 @@ +#!/bin/sh +# +# Copyright (c) 2008 Clemens Buchacher +# + +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 <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" <exp < 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/ *$//" cmp && + test_cmp exp cmp +' +rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" + +cat >exp <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 " >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 " >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 index 73af16f..0000000 --- a/t/t5541-http-push.sh +++ /dev/null @@ -1,327 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2008 Clemens Buchacher -# - -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 <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" <exp < 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/ *$//" cmp && - test_cmp exp cmp -' -rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" - -cat >exp <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 " >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 " >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 index 0000000..1a3a2b6 --- /dev/null +++ b/t/t5550-http-fetch-dumb.sh @@ -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 index 1a3a2b6..0000000 --- a/t/t5550-http-fetch.sh +++ /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 index 0000000..e07eaf3 --- /dev/null +++ b/t/t5551-http-fetch-smart.sh @@ -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 < 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 <]/{ + 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 <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 <expect_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 $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|" >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 index e07eaf3..0000000 --- a/t/t5551-http-fetch.sh +++ /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 < 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 <]/{ - 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 <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 <expect_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 $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|" >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 -- cgit v0.10.2-6-g49f6 From 32752e966d3370f6b411b42fe3a301bbd46d3eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 6 Feb 2014 22:10:36 +0700 Subject: pack-protocol.txt: clarify 'obj-id' in the last ACK after 'done' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's introduced in 1bd8c8f (git-upload-pack: Support the multi_ack protocol - 2005-10-28) but probably better documented in the commit message of 78affc4 (Add multi_ack_detailed capability to fetch-pack/upload-pack - 2009-10-30). Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano diff --git a/Documentation/technical/pack-protocol.txt b/Documentation/technical/pack-protocol.txt index c73b62f..39c6410 100644 --- a/Documentation/technical/pack-protocol.txt +++ b/Documentation/technical/pack-protocol.txt @@ -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. -- cgit v0.10.2-6-g49f6 From 087e347f2672b9a950d6da56179ca44eb7ded834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 6 Feb 2014 22:10:37 +0700 Subject: protocol-capabilities.txt: refer multi_ack_detailed back to pack-protocol.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pack-protocol.txt explains in detail how multi_ack_detailed works and what's the difference between no multi_ack, multi_ack and multi_ack_detailed. No need to repeat here. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano diff --git a/Documentation/technical/protocol-capabilities.txt b/Documentation/technical/protocol-capabilities.txt index e3e7924..cb40ebb 100644 --- a/Documentation/technical/protocol-capabilities.txt +++ b/Documentation/technical/protocol-capabilities.txt @@ -69,6 +69,12 @@ 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. + thin-pack --------- -- cgit v0.10.2-6-g49f6 From c9cd60f6fa064595e4c1a8a84b9a15cc016a09e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 6 Feb 2014 22:10:38 +0700 Subject: protocol-capabilities.txt: document no-done MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See 3e63b21 (upload-pack: Implement no-done capability - 2011-03-14) and 761ecf0 (fetch-pack: Implement no-done capability - 2011-03-14) for more information. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano diff --git a/Documentation/technical/protocol-capabilities.txt b/Documentation/technical/protocol-capabilities.txt index cb40ebb..e174343 100644 --- a/Documentation/technical/protocol-capabilities.txt +++ b/Documentation/technical/protocol-capabilities.txt @@ -75,6 +75,18 @@ 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 --------- -- cgit v0.10.2-6-g49f6 From ff62eca7d1f9716e36550adedc6e8edc35ff9a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 6 Feb 2014 22:10:39 +0700 Subject: fetch-pack: fix deepen shallow over smart http with no-done cap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In smart http, upload-pack adds new shallow lines at the beginning of each rpc response. Only shallow lines from the first rpc call are useful. After that they are thrown away. It's designed this way because upload-pack is stateless and has no idea when its shallow lines are helpful or not. So after refs are negotiated with multi_ack_detailed and the server thinks it learned enough, it sends "ACK obj-id ready", terminates the rpc call and waits for the final rpc round. The client sends "done". The server sends another response, which also has shallow lines at the beginning, and the last "ACK obj-id" line. When no-done is active, the last round is cut out, the server sends "ACK obj-id ready" and "ACK obj-id" in the same rpc response. fetch-pack is updated to recognize this and not send "done". However it still tries to consume shallow lines, which are never sent. Update the code, make sure to skip consuming shallow lines when no-done is enabled. Reported-by: Jeff King Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano diff --git a/fetch-pack.c b/fetch-pack.c index 90fdd49..f061f1f 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -439,7 +439,8 @@ done: } 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) { diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh index adf215a..098f220 100755 --- a/t/t5537-fetch-shallow.sh +++ b/t/t5537-fetch-shallow.sh @@ -199,5 +199,35 @@ EOF ) ' +# 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 10) + 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 -- cgit v0.10.2-6-g49f6 From 0232852b06cb000a3b1f5f48676c8b4d084f18ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 13 Feb 2014 20:21:14 +0700 Subject: t5537: move http tests out to t5539 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit start_httpd is supposed to be at the beginning of the test file, not the middle of it. The "test_seq" line in "no shallow lines.." test is updated to compensate missing refs that are there in t5537, but not in the new t5539. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh index 098f220..3ae9092 100755 --- a/t/t5537-fetch-shallow.sh +++ b/t/t5537-fetch-shallow.sh @@ -173,61 +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 <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 10) - 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/t5539-fetch-http-shallow.sh b/t/t5539-fetch-http-shallow.sh new file mode 100755 index 0000000..94553e1 --- /dev/null +++ b/t/t5539-fetch-http-shallow.sh @@ -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 <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 -- cgit v0.10.2-6-g49f6