]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5540-http-push.sh
Merge branch 'maint-1.7.1' into maint-1.7.2
[thirdparty/git.git] / t / t5540-http-push.sh
CommitLineData
faa4bc35
CB
1#!/bin/sh
2#
3# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
4#
5
7da4e228 6test_description='test WebDAV http-push
faa4bc35
CB
7
8This test runs various sanity checks on http-push.'
9
10. ./test-lib.sh
11
96086262
MH
12if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
13then
fadb5156 14 skip_all="skipping test, USE_CURL_MULTI is not defined"
96086262 15 test_done
96086262
MH
16fi
17
859d1fb4
CB
18LIB_HTTPD_DAV=t
19LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5540'}
bfdbee98 20. "$TEST_DIRECTORY"/lib-httpd.sh
859d1fb4 21ROOT_PATH="$PWD"
75318a3b 22start_httpd
faa4bc35
CB
23
24test_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 &&
7dce9918 37 mv hooks/post-update.sample hooks/post-update &&
ae4efe19 38 ORIG_HEAD=$(git rev-parse --verify HEAD) &&
faa4bc35 39 cd - &&
13b5481e 40 mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
faa4bc35 41'
3b2eb186 42
faa4bc35
CB
43test_expect_success 'clone remote repository' '
44 cd "$ROOT_PATH" &&
024bb125 45 git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone
faa4bc35
CB
46'
47
ae4efe19 48test_expect_success 'push to remote repository with packed refs' '
faa4bc35
CB
49 cd "$ROOT_PATH"/test_repo_clone &&
50 : >path2 &&
51 git add path2 &&
52 test_tick &&
53 git commit -m path2 &&
8ee09acd 54 HEAD=$(git rev-parse --verify HEAD) &&
b5cd2d1e 55 git push &&
8ee09acd
JS
56 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
57 test $HEAD = $(git rev-parse --verify HEAD))
faa4bc35
CB
58'
59
d8f67d20 60test_expect_success 'push already up-to-date' '
ae4efe19
SP
61 git push
62'
63
64test_expect_success 'push to remote repository with unpacked refs' '
8ee09acd
JS
65 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
66 rm packed-refs &&
ae4efe19
SP
67 git update-ref refs/heads/master $ORIG_HEAD &&
68 git --bare update-server-info) &&
8ee09acd
JS
69 git push &&
70 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
71 test $HEAD = $(git rev-parse --verify HEAD))
72'
73
4f66250d 74test_expect_success 'http-push fetches unpacked objects' '
242a9077
TRC
75 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
76 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_unpacked.git &&
77
024bb125 78 git clone $HTTPD_URL/dumb/test_repo_unpacked.git \
242a9077
TRC
79 "$ROOT_PATH"/fetch_unpacked &&
80
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 &&
86 git prune &&
024bb125 87 git push -f -v $HTTPD_URL/dumb/test_repo_unpacked.git master)
242a9077
TRC
88'
89
4f66250d 90test_expect_success 'http-push fetches packed objects' '
86d99f6d
TRC
91 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
92 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
93
024bb125 94 git clone $HTTPD_URL/dumb/test_repo_packed.git \
86d99f6d
TRC
95 "$ROOT_PATH"/test_repo_clone_packed &&
96
97 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
98 git --bare repack &&
99 git --bare prune-packed) &&
100
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 &&
106 git prune &&
024bb125 107 git push -f -v $HTTPD_URL/dumb/test_repo_packed.git master)
86d99f6d
TRC
108'
109
8ee09acd 110test_expect_success 'create and delete remote branch' '
faa4bc35
CB
111 cd "$ROOT_PATH"/test_repo_clone &&
112 git checkout -b dev &&
113 : >path3 &&
114 git add path3 &&
115 test_tick &&
116 git commit -m dev &&
117 git push origin dev &&
faa4bc35 118 git push origin :dev &&
d492b31c 119 test_must_fail git show-ref --verify refs/remotes/origin/dev
faa4bc35
CB
120'
121
466ddf90
JS
122test_expect_success 'MKCOL sends directory names with trailing slashes' '
123
124 ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
125
126'
127
2591838b
JS
128x1="[0-9a-f]"
129x2="$x1$x1"
130x5="$x1$x1$x1$x1$x1"
131x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
132x40="$x38$x2"
dfab7c14 133
2591838b
JS
134test_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] "
dfab7c14
TRC
137
138'
139
6cbd6e92
TRC
140test_http_push_nonff "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
141 "$ROOT_PATH"/test_repo_clone master
142
faa4bc35
CB
143stop_httpd
144
145test_done