3 test_description
='test smart fetching over http via http-backend'
6 if test -n "$NO_CURL"; then
7 skip_all
='skipping test, git built without http support'
11 LIB_HTTPD_PORT
=${LIB_HTTPD_PORT-'5551'}
12 .
"$TEST_DIRECTORY"/lib-httpd.sh
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" &&
26 git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
27 git push public master:master
31 > GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1
36 < Cache-Control: no-cache, max-age=0, must-revalidate
37 < Content-Type: application/x-git-upload-pack-advertisement
38 > POST /smart/repo.git/git-upload-pack HTTP/1.1
39 > Accept-Encoding: deflate, gzip
40 > Content-Type: application/x-git-upload-pack-request
41 > Accept: application/x-git-upload-pack-result
45 < Cache-Control: no-cache, max-age=0, must-revalidate
46 < Content-Type: application/x-git-upload-pack-result
48 test_expect_success
'clone http repository' '
49 GIT_CURL_VERBOSE=1 git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
50 test_cmp file clone/file &&
51 tr '\''\015'\'' Q <err |
65 /^> Accept: [*]\\/[*]/d
67 s/^> Content-Length: .*/> Content-Length: xxx/
74 /^< Content-Length: /d
75 /^< Transfer-Encoding: /d
80 test_expect_success
'fetch changes via http' '
81 echo content >>file &&
82 git commit -a -m two &&
84 (cd clone && git pull) &&
85 test_cmp file clone/file
89 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
90 POST /smart/repo.git/git-upload-pack HTTP/1.1 200
91 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
92 POST /smart/repo.git/git-upload-pack HTTP/1.1 200
94 test_expect_success
'used upload-pack service' '
100 " >act <"$HTTPD_ROOT_PATH"/access.log &&
104 test_expect_success
'follow redirects (301)' '
105 git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
108 test_expect_success
'follow redirects (302)' '
109 git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t
112 test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
114 test_expect_success EXPENSIVE
'create 50,000 tags in the repo' '
116 cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
119 echo "commit refs/heads/too-many-refs"
121 echo "committer git <git@example.com> $i +0000"
123 echo "M 644 inline bla.txt"
126 # make every commit dangling by always
127 # rewinding the branch after each commit
128 echo "reset refs/heads/too-many-refs"
130 done | git fast-import --export-marks=marks &&
132 # now assign tags to all the dangling commits we created above
133 tag=$("$PERL_PATH" -e "print \"bla\" x 30") &&
134 sed -e "s/^:\(.\+\) \(.\+\)$/\2 refs\/tags\/$tag-\1/" <marks >>packed-refs
138 test_expect_success EXPENSIVE
'clone the 50,000 tag repo to check OS command line overflow' '
139 git clone $HTTPD_URL/smart/repo.git too-many-refs 2>err &&
140 test_line_count = 0 err