]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5540-http-push.sh
t5540-http-push: test fetching of packed objects
[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 &&
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" &&
45 git clone $HTTPD_URL/test_repo.git test_repo_clone
46'
47
8ee09acd 48test_expect_failure '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
8ee09acd
JS
60test_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))
68'
69
242a9077
TRC
70test_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 &&
73
74 git clone $HTTPD_URL/test_repo_unpacked.git \
75 "$ROOT_PATH"/fetch_unpacked &&
76
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)
84'
85
86d99f6d
TRC
86test_expect_failure 'http-push fetches packed objects' '
87 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git \
88 "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
89
90 git clone $HTTPD_URL/test_repo_packed.git \
91 "$ROOT_PATH"/test_repo_clone_packed &&
92
93 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo_packed.git &&
94 git --bare repack &&
95 git --bare prune-packed) &&
96
97 # By reset, we force git to retrieve the packed object
98 (cd "$ROOT_PATH"/test_repo_clone_packed &&
99 git reset --hard HEAD^ &&
100 git remote rm origin &&
101 git reflog expire --expire=0 --all &&
102 git prune &&
103 git push -f -v $HTTPD_URL/test_repo_packed.git master)
104'
105
8ee09acd 106test_expect_success 'create and delete remote branch' '
faa4bc35
CB
107 cd "$ROOT_PATH"/test_repo_clone &&
108 git checkout -b dev &&
109 : >path3 &&
110 git add path3 &&
111 test_tick &&
112 git commit -m dev &&
113 git push origin dev &&
114 git fetch &&
115 git push origin :dev &&
116 git branch -d -r origin/dev &&
117 git fetch &&
d492b31c 118 test_must_fail git show-ref --verify refs/remotes/origin/dev
faa4bc35
CB
119'
120
466ddf90
JS
121test_expect_success 'MKCOL sends directory names with trailing slashes' '
122
123 ! grep "\"MKCOL.*[^/] HTTP/[^ ]*\"" < "$HTTPD_ROOT_PATH"/access.log
124
125'
126
2591838b
JS
127x1="[0-9a-f]"
128x2="$x1$x1"
129x5="$x1$x1$x1$x1$x1"
130x38="$x5$x5$x5$x5$x5$x5$x5$x1$x1$x1"
131x40="$x38$x2"
dfab7c14 132
2591838b
JS
133test_expect_success 'PUT and MOVE sends object to URLs with SHA-1 hash suffix' '
134 sed -e "s/PUT /OP /" -e "s/MOVE /OP /" "$HTTPD_ROOT_PATH"/access.log |
135 grep -e "\"OP .*/objects/$x2/${x38}_$x40 HTTP/[.0-9]*\" 20[0-9] "
dfab7c14
TRC
136
137'
138
faa4bc35
CB
139stop_httpd
140
141test_done