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 '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 &&
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) &&
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 &&
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 &&
79 git --bare prune-packed
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` &&
89 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
91 mkdir repo_bad1.git &&
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` &&
104 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
106 mkdir repo_bad2.git &&
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