Merge branch 'ao/send-email-irt'
[git/kirr.git] / t / t5550-http-fetch.sh
blob2fb48d09edb47129d9cea8b9686e46a6d8f35615
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 &&
34 test_cmp file clone/file
37 test_expect_success 'fetch changes via http' '
38 echo content >>file &&
39 git commit -a -m two &&
40 git push public
41 (cd clone && git pull) &&
42 test_cmp file clone/file
45 test_expect_success 'http remote detects correct HEAD' '
46 git push public master:other &&
47 (cd clone &&
48 git remote set-head origin -d &&
49 git remote set-head origin -a &&
50 git symbolic-ref refs/remotes/origin/HEAD > output &&
51 echo refs/remotes/origin/master > expect &&
52 test_cmp expect output
56 test_expect_success 'fetch packed objects' '
57 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
58 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
59 git --bare repack &&
60 git --bare prune-packed
61 ) &&
62 git clone $HTTPD_URL/dumb/repo_pack.git
65 test_expect_success 'fetch notices corrupt pack' '
66 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
67 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
68 p=`ls objects/pack/pack-*.pack` &&
69 chmod u+w $p &&
70 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
71 ) &&
72 mkdir repo_bad1.git &&
73 (cd repo_bad1.git &&
74 git --bare init &&
75 test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad1.git &&
76 test 0 = `ls objects/pack/pack-*.pack | wc -l`
80 test_expect_success 'fetch notices corrupt idx' '
81 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
82 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
83 p=`ls objects/pack/pack-*.idx` &&
84 chmod u+w $p &&
85 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
86 ) &&
87 mkdir repo_bad2.git &&
88 (cd repo_bad2.git &&
89 git --bare init &&
90 test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad2.git &&
91 test 0 = `ls objects/pack | wc -l`
95 test_expect_success 'did not use upload-pack service' '
96 grep '/git-upload-pack' <"$HTTPD_ROOT_PATH"/access.log >act
97 : >exp
98 test_cmp exp act
101 stop_httpd
102 test_done