3 # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
6 test_description
='test WebDAV http-push
8 This test runs various sanity checks on http-push.'
12 if git http-push
> /dev
/null
2>&1 ||
[ $?
-eq 128 ]
14 skip_all
="skipping test, USE_CURL_MULTI is not defined"
19 LIB_HTTPD_PORT
=${LIB_HTTPD_PORT-'5540'}
20 .
"$TEST_DIRECTORY"/lib-httpd.sh
24 test_expect_success
'setup remote repository' '
32 git commit -m initial &&
34 git clone --bare test_repo test_repo.git &&
36 git --bare update-server-info &&
37 mv hooks/post-update.sample hooks/post-update &&
38 ORIG_HEAD=$(git rev-parse --verify HEAD) &&
40 mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
43 test_expect_success
'create password-protected repository' '
44 mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb" &&
45 cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
46 "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git"
49 test_expect_success
'setup askpass helper' '
50 cat >askpass <<-\EOF &&
55 GIT_ASKPASS="$PWD/askpass" &&
59 test_expect_success
'clone remote repository' '
61 git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone
64 test_expect_success
'push to remote repository with packed refs' '
65 cd "$ROOT_PATH"/test_repo_clone &&
69 git commit -m path2 &&
70 HEAD=$(git rev-parse --verify HEAD) &&
72 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
73 test $HEAD = $(git rev-parse --verify HEAD))
76 test_expect_success
'push already up-to-date' '
80 test_expect_success
'push to remote repository with unpacked refs' '
81 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
83 git update-ref refs/heads/master $ORIG_HEAD &&
84 git --bare update-server-info) &&
86 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
87 test $HEAD = $(git rev-parse --verify HEAD))
90 test_expect_success
'http-push fetches unpacked objects' '
91 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
92 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_unpacked.git &&
94 git clone $HTTPD_URL/dumb/test_repo_unpacked.git \
95 "$ROOT_PATH"/fetch_unpacked &&
97 # By reset, we force git to retrieve the object
98 (cd "$ROOT_PATH"/fetch_unpacked &&
99 git reset --hard HEAD^ &&
100 git remote rm origin &&
101 git reflog expire --expire=0 --all &&
103 git push -f -v $HTTPD_URL/dumb/test_repo_unpacked.git master)
106 test_expect_success
'http-push fetches packed objects' '
107 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
108 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
110 git clone $HTTPD_URL/dumb/test_repo_packed.git \
111 "$ROOT_PATH"/test_repo_clone_packed &&
113 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
115 git --bare prune-packed) &&
117 # By reset, we force git to retrieve the packed object
118 (cd "$ROOT_PATH"/test_repo_clone_packed &&
119 git reset --hard HEAD^ &&
120 git remote rm origin &&
121 git reflog expire --expire=0 --all &&
123 git push -f -v $HTTPD_URL/dumb/test_repo_packed.git master)
126 test_expect_success
'create and delete remote branch' '
127 cd "$ROOT_PATH"/test_repo_clone &&
128 git checkout -b dev &&
133 git push origin dev &&
134 git push origin :dev &&
135 test_must_fail git show-ref --verify refs/remotes/origin/dev
138 test_expect_success
'MKCOL sends directory names with trailing slashes' '
140 ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
147 x38
="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
150 test_expect_success
'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
154 -e "s|/objects/$x2/${x38}_$x40|WANTED_PATH_REQUEST|" \
155 "$HTTPD_ROOT_PATH"/access.log |
156 grep -e "\"OP .*WANTED_PATH_REQUEST HTTP/[.0-9]*\" 20[0-9] "
160 test_http_push_nonff
"$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
161 "$ROOT_PATH"/test_repo_clone master
163 test_expect_success
'push to password-protected repository (user in URL)' '
164 test_commit pw-user &&
165 git push "$HTTPD_URL_USER/auth/dumb/test_repo.git" HEAD &&
166 git rev-parse --verify HEAD >expect &&
167 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
168 rev-parse --verify HEAD >actual &&
169 test_cmp expect actual
172 test_expect_failure
'push to password-protected repository (no user in URL)' '
173 test_commit pw-nouser &&
174 git push "$HTTPD_URL/auth/dumb/test_repo.git" HEAD &&
175 git rev-parse --verify HEAD >expect &&
176 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
177 rev-parse --verify HEAD >actual &&
178 test_cmp expect actual