3 # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
6 test_description
='test http-push
8 This test runs various sanity checks on http-push.'
14 LIB_HTTPD_PORT
=${LIB_HTTPD_PORT-'5540'}
16 if git http-push
> /dev
/null
2>&1 ||
[ $?
-eq 128 ]
18 say
"skipping test, USE_CURL_MULTI is not defined"
22 .
"$TEST_DIRECTORY"/lib-httpd.sh
25 test_expect_success
'setup remote repository' '
33 git commit -m initial &&
35 git clone --bare test_repo test_repo.git &&
37 git --bare update-server-info &&
38 mv hooks/post-update.sample hooks/post-update &&
39 ORIG_HEAD=$(git rev-parse --verify HEAD) &&
41 mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
44 test_expect_success
'clone remote repository' '
46 git clone $HTTPD_URL/test_repo.git test_repo_clone
49 test_expect_success
'push to remote repository with packed refs' '
50 cd "$ROOT_PATH"/test_repo_clone &&
54 git commit -m path2 &&
55 HEAD=$(git rev-parse --verify HEAD) &&
57 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
58 test $HEAD = $(git rev-parse --verify HEAD))
61 test_expect_success
'push already up-to-date' '
65 test_expect_success
'push to remote repository with unpacked refs' '
66 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
68 git update-ref refs/heads/master $ORIG_HEAD &&
69 git --bare update-server-info) &&
71 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
72 test $HEAD = $(git rev-parse --verify HEAD))
75 test_expect_success
'http-push fetches unpacked objects' '
76 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
77 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_unpacked.git &&
79 git clone $HTTPD_URL/test_repo_unpacked.git \
80 "$ROOT_PATH"/fetch_unpacked &&
82 # By reset, we force git to retrieve the object
83 (cd "$ROOT_PATH"/fetch_unpacked &&
84 git reset --hard HEAD^ &&
85 git remote rm origin &&
86 git reflog expire --expire=0 --all &&
88 git push -f -v $HTTPD_URL/test_repo_unpacked.git master)
91 test_expect_success
'http-push fetches packed objects' '
92 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
93 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
95 git clone $HTTPD_URL/test_repo_packed.git \
96 "$ROOT_PATH"/test_repo_clone_packed &&
98 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
100 git --bare prune-packed) &&
102 # By reset, we force git to retrieve the packed object
103 (cd "$ROOT_PATH"/test_repo_clone_packed &&
104 git reset --hard HEAD^ &&
105 git remote rm origin &&
106 git reflog expire --expire=0 --all &&
108 git push -f -v $HTTPD_URL/test_repo_packed.git master)
111 test_expect_success
'create and delete remote branch' '
112 cd "$ROOT_PATH"/test_repo_clone &&
113 git checkout -b dev &&
118 git push origin dev &&
120 git push origin :dev &&
122 test_must_fail git show-ref --verify refs/remotes/origin/dev
125 test_expect_success
'MKCOL sends directory names with trailing slashes' '
127 ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
134 x38
="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
137 test_expect_success
'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
138 sed -e "s/PUT /OP /" -e "s/MOVE /OP /" "$HTTPD_ROOT_PATH"/access.log |
139 grep -e "\"OP .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\" 20[0-9] "