3 test_description
='test dumb fetching over http via static file'
6 if test -n "$NO_CURL"; then
7 skip_all
='skipping test, git built without http support'
11 .
"$TEST_DIRECTORY"/lib-httpd.sh
12 LIB_HTTPD_PORT
=${LIB_HTTPD_PORT-'5550'}
15 test_expect_success
'setup repository' '
21 test_expect_success
'create http-accessible bare repository' '
22 mkdir "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
23 (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
25 echo "exec git update-server-info" >hooks/post-update &&
26 chmod +x hooks/post-update
28 git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
29 git push public master:master
32 test_expect_success
'clone http repository' '
33 git clone $HTTPD_URL/dumb/repo.git clone-tmpl &&
34 cp -R clone-tmpl clone &&
35 test_cmp file clone/file
38 test_expect_success
'fetch changes via http' '
39 echo content >>file &&
40 git commit -a -m two &&
42 (cd clone && git pull) &&
43 test_cmp file clone/file
46 test_expect_success
'fetch changes via manual http-fetch' '
47 cp -R clone-tmpl clone2 &&
49 HEAD=$(git rev-parse --verify HEAD) &&
51 git http-fetch -a -w heads/master-new $HEAD $(git config remote.origin.url) &&
52 git checkout master-new &&
53 test $HEAD = $(git rev-parse --verify HEAD)) &&
54 test_cmp file clone2/file
57 test_expect_success
'http remote detects correct HEAD' '
58 git push public master:other &&
60 git remote set-head origin -d &&
61 git remote set-head origin -a &&
62 git symbolic-ref refs/remotes/origin/HEAD > output &&
63 echo refs/remotes/origin/master > expect &&
64 test_cmp expect output
68 test_expect_success
'fetch packed objects' '
69 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
70 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
72 git --bare prune-packed
74 git clone $HTTPD_URL/dumb/repo_pack.git
77 test_expect_success
'fetch notices corrupt pack' '
78 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
79 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
80 p=`ls objects/pack/pack-*.pack` &&
82 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
84 mkdir repo_bad1.git &&
87 test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad1.git &&
88 test 0 = `ls objects/pack/pack-*.pack | wc -l`
92 test_expect_success
'fetch notices corrupt idx' '
93 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
94 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
95 p=`ls objects/pack/pack-*.idx` &&
97 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
99 mkdir repo_bad2.git &&
102 test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad2.git &&
103 test 0 = `ls objects/pack | wc -l`
107 test_expect_success
'did not use upload-pack service' '
108 grep '/git-upload-pack
' <"$HTTPD_ROOT_PATH"/access.log >act