gitweb.conf.txt: say "build-time", not "built-time"
[git/mjg.git] / t / t5550-http-fetch.sh
bloba1883ca6b649a236e5e08a5e4b76d1479353dcac
1 #!/bin/sh
3 test_description='test dumb fetching over http via static file'
4 . ./test-lib.sh
6 if test -n "$NO_CURL"; then
7 skip_all='skipping test, git built without http support'
8 test_done
9 fi
11 . "$TEST_DIRECTORY"/lib-httpd.sh
12 LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'5550'}
13 start_httpd
15 test_expect_success 'setup repository' '
16 echo content >file &&
17 git add file &&
18 git commit -m one
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" &&
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
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 'clone http repository with authentication' '
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
45 test_expect_success 'fetch changes via http' '
46 echo content >>file &&
47 git commit -a -m two &&
48 git push public &&
49 (cd clone && git pull) &&
50 test_cmp file clone/file
53 test_expect_success 'fetch changes via manual http-fetch' '
54 cp -R clone-tmpl clone2 &&
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
64 test_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
75 test_expect_success 'fetch packed objects' '
76 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
77 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
78 git --bare repack &&
79 git --bare prune-packed
80 ) &&
81 git clone $HTTPD_URL/dumb/repo_pack.git
84 test_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`
99 test_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`
114 test_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
120 stop_httpd
121 test_done