]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5550-http-fetch.sh
Merge branch 'ae/better-template-failure-report'
[thirdparty/git.git] / t / t5550-http-fetch.sh
CommitLineData
119c8eee
JK
1#!/bin/sh
2
7da4e228 3test_description='test dumb fetching over http via static file'
119c8eee
JK
4. ./test-lib.sh
5
6if test -n "$NO_CURL"; then
fadb5156 7 skip_all='skipping test, git built without http support'
119c8eee
JK
8 test_done
9fi
10
11. "$TEST_DIRECTORY"/lib-httpd.sh
12LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5550'}
13start_httpd
14
15test_expect_success 'setup repository' '
16 echo content >file &&
17 git add file &&
18 git commit -m one
19'
20
21test_expect_success 'create http-accessible bare repository' '
22 mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
23 (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
24 git --bare init &&
25 echo "exec git update-server-info" >hooks/post-update &&
26 chmod +x hooks/post-update
27 ) &&
28 git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
29 git push public master:master
30'
31
32test_expect_success 'clone http repository' '
6cfc0286
TRC
33 git clone $HTTPD_URL/dumb/repo.git clone-tmpl &&
34 cp -R clone-tmpl clone &&
119c8eee
JK
35 test_cmp file clone/file
36'
37
f39f72d8 38test_expect_success 'clone http repository with authentication' '
3cf8fe1d
GC
39 mkdir "$HTTPD_DOCUMENT_ROOT_PATH/auth/" &&
40 cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" "$HTTPD_DOCUMENT_ROOT_PATH/auth/repo.git" &&
41 git clone $AUTH_HTTPD_URL/auth/repo.git clone-auth &&
42 test_cmp file clone-auth/file
43'
44
119c8eee
JK
45test_expect_success 'fetch changes via http' '
46 echo content >>file &&
47 git commit -a -m two &&
2bcd9ec5 48 git push public &&
119c8eee
JK
49 (cd clone && git pull) &&
50 test_cmp file clone/file
51'
52
6cfc0286
TRC
53test_expect_success 'fetch changes via manual http-fetch' '
54 cp -R clone-tmpl clone2 &&
55
56 HEAD=$(git rev-parse --verify HEAD) &&
57 (cd clone2 &&
58 git http-fetch -a -w heads/master-new $HEAD $(git config remote.origin.url) &&
59 git checkout master-new &&
60 test $HEAD = $(git rev-parse --verify HEAD)) &&
61 test_cmp file clone2/file
62'
63
fbb074c2
JK
64test_expect_success 'http remote detects correct HEAD' '
65 git push public master:other &&
66 (cd clone &&
67 git remote set-head origin -d &&
68 git remote set-head origin -a &&
69 git symbolic-ref refs/remotes/origin/HEAD > output &&
70 echo refs/remotes/origin/master > expect &&
71 test_cmp expect output
72 )
73'
74
96a4f187
TRC
75test_expect_success 'fetch packed objects' '
76 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
d761b2ac
SP
77 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
78 git --bare repack &&
79 git --bare prune-packed
80 ) &&
024bb125 81 git clone $HTTPD_URL/dumb/repo_pack.git
96a4f187
TRC
82'
83
fe72d420
SP
84test_expect_success 'fetch notices corrupt pack' '
85 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
86 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
87 p=`ls objects/pack/pack-*.pack` &&
88 chmod u+w $p &&
89 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
90 ) &&
91 mkdir repo_bad1.git &&
92 (cd repo_bad1.git &&
93 git --bare init &&
94 test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad1.git &&
95 test 0 = `ls objects/pack/pack-*.pack | wc -l`
96 )
97'
98
750ef425
SP
99test_expect_success 'fetch notices corrupt idx' '
100 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
101 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
102 p=`ls objects/pack/pack-*.idx` &&
103 chmod u+w $p &&
104 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
105 ) &&
106 mkdir repo_bad2.git &&
107 (cd repo_bad2.git &&
108 git --bare init &&
109 test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad2.git &&
110 test 0 = `ls objects/pack | wc -l`
111 )
112'
113
7da4e228
SP
114test_expect_success 'did not use upload-pack service' '
115 grep '/git-upload-pack' <"$HTTPD_ROOT_PATH"/access.log >act
116 : >exp
117 test_cmp exp act
118'
119
119c8eee
JK
120stop_httpd
121test_done