t5540-http-push: test fetching of loose objects
[git/kusma.git] / t / t5540-http-push.sh
blob65a41dbe5e496b153d14a0d5438d9e0f77f6192f
1 #!/bin/sh
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.'
10 . ./test-lib.sh
12 ROOT_PATH="$PWD"
13 LIB_HTTPD_DAV=t
14 LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5540'}
16 if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
17 then
18 say "skipping test, USE_CURL_MULTI is not defined"
19 test_done
22 . "$TEST_DIRECTORY"/lib-httpd.sh
23 start_httpd
25 test_expect_success 'setup remote repository' '
26 cd "$ROOT_PATH" &&
27 mkdir test_repo &&
28 cd test_repo &&
29 git init &&
30 : >path1 &&
31 git add path1 &&
32 test_tick &&
33 git commit -m initial &&
34 cd - &&
35 git clone --bare test_repo test_repo.git &&
36 cd test_repo.git &&
37 git --bare update-server-info &&
38 mv hooks/post-update.sample hooks/post-update &&
39 cd - &&
40 mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
43 test_expect_success 'clone remote repository' '
44 cd "$ROOT_PATH" &&
45 git clone $HTTPD_URL/test_repo.git test_repo_clone
48 test_expect_failure 'push to remote repository with packed refs' '
49 cd "$ROOT_PATH"/test_repo_clone &&
50 : >path2 &&
51 git add path2 &&
52 test_tick &&
53 git commit -m path2 &&
54 HEAD=$(git rev-parse --verify HEAD) &&
55 git push &&
56 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
57 test $HEAD = $(git rev-parse --verify HEAD))
60 test_expect_success ' push to remote repository with unpacked refs' '
61 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
62 rm packed-refs &&
63 git update-ref refs/heads/master \
64 0c973ae9bd51902a28466f3850b543fa66a6aaf4) &&
65 git push &&
66 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
67 test $HEAD = $(git rev-parse --verify HEAD))
70 test_expect_failure 'http-push fetches unpacked objects' '
71 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
72 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_unpacked.git &&
74 git clone $HTTPD_URL/test_repo_unpacked.git \
75 "$ROOT_PATH"/fetch_unpacked &&
77 # By reset, we force git to retrieve the object
78 (cd "$ROOT_PATH"/fetch_unpacked &&
79 git reset --hard HEAD^ &&
80 git remote rm origin &&
81 git reflog expire --expire=0 --all &&
82 git prune &&
83 git push -f -v $HTTPD_URL/test_repo_unpacked.git master)
86 test_expect_success 'create and delete remote branch' '
87 cd "$ROOT_PATH"/test_repo_clone &&
88 git checkout -b dev &&
89 : >path3 &&
90 git add path3 &&
91 test_tick &&
92 git commit -m dev &&
93 git push origin dev &&
94 git fetch &&
95 git push origin :dev &&
96 git branch -d -r origin/dev &&
97 git fetch &&
98 test_must_fail git show-ref --verify refs/remotes/origin/dev
101 test_expect_success 'MKCOL sends directory names with trailing slashes' '
103 ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
107 x1="[0-9a-f]"
108 x2="$x1$x1"
109 x5="$x1$x1$x1$x1$x1"
110 x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
111 x40="$x38$x2"
113 test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
114 sed -e "s/PUT /OP /" -e "s/MOVE /OP /" "$HTTPD_ROOT_PATH"/access.log |
115 grep -e "\"OP .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\" 20[0-9] "
119 stop_httpd
121 test_done