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
33 > GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1
38 < Cache-Control: no-cache, max-age=0, must-revalidate
39 < Content-Type: application/x-git-upload-pack-advertisement
40 > POST /smart/repo.git/git-upload-pack HTTP/1.1
41 > Accept-Encoding: deflate, gzip
42 > Content-Type: application/x-git-upload-pack-request
43 > Accept: application/x-git-upload-pack-result
47 < Cache-Control: no-cache, max-age=0, must-revalidate
48 < Content-Type: application/x-git-upload-pack-result
50 test_expect_success
'clone http repository' '
51 GIT_CURL_VERBOSE=1 git clone --quiet $HTTPD_URL/smart/repo.git clone 2>err &&
52 test_cmp file clone/file &&
53 tr '\''\015'\'' Q <err |
67 /^> Accept: [*]\\/[*]/d
69 s/^> Content-Length: .*/> Content-Length: xxx/
76 /^< Content-Length: /d
77 /^< Transfer-Encoding: /d
82 test_expect_success
'fetch changes via http' '
83 echo content >>file &&
84 git commit -a -m two &&
86 (cd clone && git pull) &&
87 test_cmp file clone/file
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
93 GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
94 POST /smart/repo.git/git-upload-pack HTTP/1.1 200
96 test_expect_success
'used upload-pack service' '
102 " >act <"$HTTPD_ROOT_PATH"/access.log &&
106 test_expect_success
'follow redirects (301)' '
107 git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
110 test_expect_success
'follow redirects (302)' '
111 git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t
114 test_expect_success
'clone from password-protected repository' '
116 set_askpass user@host &&
117 git clone --bare "$HTTPD_URL/auth/smart/repo.git" smart-auth &&
118 expect_askpass both user@host &&
119 git --git-dir=smart-auth log -1 --format=%s >actual &&
120 test_cmp expect actual
123 test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
125 test_expect_success EXPENSIVE
'create 50,000 tags in the repo' '
127 cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
130 echo "commit refs/heads/too-many-refs"
132 echo "committer git <git@example.com> $i +0000"
134 echo "M 644 inline bla.txt"
137 # make every commit dangling by always
138 # rewinding the branch after each commit
139 echo "reset refs/heads/too-many-refs"
141 done | git fast-import --export-marks=marks &&
143 # now assign tags to all the dangling commits we created above
144 tag=$(perl -e "print \"bla\" x 30") &&
145 sed -e "s/^:\(.\+\) \(.\+\)$/\2 refs\/tags\/$tag-\1/" <marks >>packed-refs
149 test_expect_success EXPENSIVE
'clone the 50,000 tag repo to check OS command line overflow' '
150 git clone $HTTPD_URL/smart/repo.git too-many-refs 2>err &&
151 test_line_count = 0 err