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 'clone remote repository' '
45 git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone
48 test_expect_success 'push to remote repository with packed refs' '
49 cd "$ROOT_PATH"/test_repo_clone &&
53 git commit -m path2 &&
54 HEAD=$(git rev-parse --verify HEAD) &&
56 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
57 test $HEAD = $(git rev-parse --verify HEAD))
60 test_expect_success 'push already up-to-date' '
64 test_expect_success 'push to remote repository with unpacked refs' '
65 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
67 git update-ref refs/heads/master $ORIG_HEAD &&
68 git --bare update-server-info) &&
70 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
71 test $HEAD = $(git rev-parse --verify HEAD))
74 test_expect_success 'http-push fetches unpacked objects' '
75 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
76 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_unpacked.git &&
78 git clone $HTTPD_URL/dumb/test_repo_unpacked.git \
79 "$ROOT_PATH"/fetch_unpacked &&
81 # By reset, we force git to retrieve the object
82 (cd "$ROOT_PATH"/fetch_unpacked &&
83 git reset --hard HEAD^ &&
84 git remote rm origin &&
85 git reflog expire --expire=0 --all &&
87 git push -f -v $HTTPD_URL/dumb/test_repo_unpacked.git master)
90 test_expect_success 'http-push fetches packed objects' '
91 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
92 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
94 git clone $HTTPD_URL/dumb/test_repo_packed.git \
95 "$ROOT_PATH"/test_repo_clone_packed &&
97 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
99 git --bare prune-packed) &&
101 # By reset, we force git to retrieve the packed object
102 (cd "$ROOT_PATH"/test_repo_clone_packed &&
103 git reset --hard HEAD^ &&
104 git remote rm origin &&
105 git reflog expire --expire=0 --all &&
107 git push -f -v $HTTPD_URL/dumb/test_repo_packed.git master)
110 test_expect_success 'create and delete remote branch' '
111 cd "$ROOT_PATH"/test_repo_clone &&
112 git checkout -b dev &&
117 git push origin dev &&
118 git push origin :dev &&
119 test_must_fail git show-ref --verify refs/remotes/origin/dev
122 test_expect_success 'MKCOL sends directory names with trailing slashes' '
124 ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
131 x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
134 test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
135 sed -e "s/PUT /OP /" -e "s/MOVE /OP /" "$HTTPD_ROOT_PATH"/access.log |
136 grep -e "\"OP .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\" 20[0-9] "
140 test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
141 "$ROOT_PATH"/test_repo_clone master