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