t7800: Test difftool passing arguments to diff
[git/gitweb.git] / t / t5540-http-push.sh
blob1eea64765608dc4a2e4b19eec4155890306e5d59
1 #!/bin/sh
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.'
10 . ./test-lib.sh
12 if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
13 then
14 skip_all="skipping test, USE_CURL_MULTI is not defined"
15 test_done
18 LIB_HTTPD_DAV=t
19 LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5540'}
20 . "$TEST_DIRECTORY"/lib-httpd.sh
21 ROOT_PATH="$PWD"
22 start_httpd
24 test_expect_success 'setup remote repository' '
25 cd "$ROOT_PATH" &&
26 mkdir test_repo &&
27 cd test_repo &&
28 git init &&
29 : >path1 &&
30 git add path1 &&
31 test_tick &&
32 git commit -m initial &&
33 cd - &&
34 git clone --bare test_repo test_repo.git &&
35 cd 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) &&
39 cd - &&
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 &&
51 #!/bin/sh
52 echo user@host
53 EOF
54 chmod +x askpass &&
55 GIT_ASKPASS="$PWD/askpass" &&
56 export GIT_ASKPASS
59 test_expect_success 'clone remote repository' '
60 cd "$ROOT_PATH" &&
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 &&
66 : >path2 &&
67 git add path2 &&
68 test_tick &&
69 git commit -m path2 &&
70 HEAD=$(git rev-parse --verify HEAD) &&
71 git push &&
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' '
77 git push
80 test_expect_success 'push to remote repository with unpacked refs' '
81 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
82 rm packed-refs &&
83 git update-ref refs/heads/master $ORIG_HEAD &&
84 git --bare update-server-info) &&
85 git push &&
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 &&
102 git prune &&
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 &&
114 git --bare repack &&
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 &&
122 git prune &&
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 &&
129 : >path3 &&
130 git add path3 &&
131 test_tick &&
132 git commit -m 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
144 x1="[0-9a-f]"
145 x2="$x1$x1"
146 x5="$x1$x1$x1$x1$x1"
147 x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
148 x40="$x38$x2"
150 test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
151 sed \
152 -e "s/PUT /OP /" \
153 -e "s/MOVE /OP /" \
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
181 stop_httpd
183 test_done