t/lib-httpd.sh: skip tests if NO_CURL is defined
[git] / t / t5539-fetch-http-shallow.sh
1 #!/bin/sh
2
3 test_description='fetch/clone from a shallow clone over http'
4
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-httpd.sh
7 start_httpd
8
9 commit() {
10         echo "$1" >tracked &&
11         git add tracked &&
12         git commit -m "$1"
13 }
14
15 test_expect_success 'setup shallow clone' '
16         commit 1 &&
17         commit 2 &&
18         commit 3 &&
19         commit 4 &&
20         commit 5 &&
21         commit 6 &&
22         commit 7 &&
23         git clone --no-local --depth=5 .git shallow &&
24         git config --global transfer.fsckObjects true
25 '
26
27 test_expect_success 'clone http repository' '
28         git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
29         git clone $HTTPD_URL/smart/repo.git clone &&
30         (
31         cd clone &&
32         git fsck &&
33         git log --format=%s origin/master >actual &&
34         cat <<EOF >expect &&
35 7
36 6
37 5
38 4
39 3
40 EOF
41         test_cmp expect actual
42         )
43 '
44
45 # This test is tricky. We need large enough "have"s that fetch-pack
46 # will put pkt-flush in between. Then we need a "have" the server
47 # does not have, it'll send "ACK %s ready"
48 test_expect_success 'no shallow lines after receiving ACK ready' '
49         (
50                 cd shallow &&
51                 for i in $(test_seq 15)
52                 do
53                         git checkout --orphan unrelated$i &&
54                         test_commit unrelated$i &&
55                         git push -q "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
56                                 refs/heads/unrelated$i:refs/heads/unrelated$i &&
57                         git push -q ../clone/.git \
58                                 refs/heads/unrelated$i:refs/heads/unrelated$i ||
59                         exit 1
60                 done &&
61                 git checkout master &&
62                 test_commit new &&
63                 git push  "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" master
64         ) &&
65         (
66                 cd clone &&
67                 git checkout --orphan newnew &&
68                 test_commit new-too &&
69                 GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" git fetch --depth=2 &&
70                 grep "fetch-pack< ACK .* ready" ../trace &&
71                 ! grep "fetch-pack> done" ../trace
72         )
73 '
74
75 stop_httpd
76 test_done