http-push: Normalise directory names when pushing to some WebDAV servers
[git.git] / t / t5550-http-fetch.sh
blobd3bf5cefb14d5228904b80b538e170aa294584a4
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 'fetch changes via http' '
39 echo content >>file &&
40 git commit -a -m two &&
41 git push public &&
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) &&
50 (cd clone2 &&
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 &&
59 (cd clone &&
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 &&
71 git --bare repack &&
72 git --bare prune-packed
73 ) &&
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` &&
81 chmod u+w $p &&
82 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
83 ) &&
84 mkdir repo_bad1.git &&
85 (cd repo_bad1.git &&
86 git --bare init &&
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` &&
96 chmod u+w $p &&
97 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
98 ) &&
99 mkdir repo_bad2.git &&
100 (cd repo_bad2.git &&
101 git --bare init &&
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
109 : >exp
110 test_cmp exp act
113 stop_httpd
114 test_done