pack-bitmap: bounds-check size of cache extension
[git/debian.git] / t / t5539-fetch-http-shallow.sh
blob82aa99ae870e4064db0e335b43233ddd2b0e7173
1 #!/bin/sh
3 test_description='fetch/clone from a shallow clone over http'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-httpd.sh
7 start_httpd
9 commit() {
10 echo "$1" >tracked &&
11 git add tracked &&
12 test_tick &&
13 git commit -m "$1"
16 test_expect_success 'setup shallow clone' '
17 test_tick=1500000000 &&
18 commit 1 &&
19 commit 2 &&
20 commit 3 &&
21 commit 4 &&
22 commit 5 &&
23 commit 6 &&
24 commit 7 &&
25 git clone --no-local --depth=5 .git shallow &&
26 git config --global transfer.fsckObjects true
29 test_expect_success 'clone http repository' '
30 git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
31 git clone $HTTPD_URL/smart/repo.git clone &&
33 cd clone &&
34 git fsck &&
35 git log --format=%s origin/master >actual &&
36 cat <<EOF >expect &&
42 EOF
43 test_cmp expect actual
47 # This test is tricky. We need large enough "have"s that fetch-pack
48 # will put pkt-flush in between. Then we need a "have" the server
49 # does not have, it'll send "ACK %s ready"
50 test_expect_success 'no shallow lines after receiving ACK ready' '
52 cd shallow &&
53 for i in $(test_seq 15)
55 git checkout --orphan unrelated$i &&
56 test_commit unrelated$i &&
57 git push -q "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
58 refs/heads/unrelated$i:refs/heads/unrelated$i &&
59 git push -q ../clone/.git \
60 refs/heads/unrelated$i:refs/heads/unrelated$i ||
61 exit 1
62 done &&
63 git checkout master &&
64 test_commit new &&
65 git push "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" master
66 ) &&
68 cd clone &&
69 git checkout --orphan newnew &&
70 test_tick=1400000000 &&
71 test_commit new-too &&
72 # NEEDSWORK: If the overspecification of the expected result is reduced, we
73 # might be able to run this test in all protocol versions.
74 GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION=0 \
75 git fetch --depth=2 &&
76 grep "fetch-pack< ACK .* ready" ../trace &&
77 ! grep "fetch-pack> done" ../trace
81 test_expect_success 'clone shallow since ...' '
82 test_create_repo shallow-since &&
84 cd shallow-since &&
85 GIT_COMMITTER_DATE="100000000 +0700" git commit --allow-empty -m one &&
86 GIT_COMMITTER_DATE="200000000 +0700" git commit --allow-empty -m two &&
87 GIT_COMMITTER_DATE="300000000 +0700" git commit --allow-empty -m three &&
88 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-since.git" &&
89 git clone --shallow-since "300000000 +0700" $HTTPD_URL/smart/shallow-since.git ../shallow11 &&
90 git -C ../shallow11 log --pretty=tformat:%s HEAD >actual &&
91 echo three >expected &&
92 test_cmp expected actual
96 test_expect_success 'fetch shallow since ...' '
97 git -C shallow11 fetch --shallow-since "200000000 +0700" origin &&
98 git -C shallow11 log --pretty=tformat:%s origin/master >actual &&
99 cat >expected <<-\EOF &&
100 three
103 test_cmp expected actual
106 test_expect_success 'shallow clone exclude tag two' '
107 test_create_repo shallow-exclude &&
109 cd shallow-exclude &&
110 test_commit one &&
111 test_commit two &&
112 test_commit three &&
113 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-exclude.git" &&
114 git clone --shallow-exclude two $HTTPD_URL/smart/shallow-exclude.git ../shallow12 &&
115 git -C ../shallow12 log --pretty=tformat:%s HEAD >actual &&
116 echo three >expected &&
117 test_cmp expected actual
121 test_expect_success 'fetch exclude tag one' '
122 git -C shallow12 fetch --shallow-exclude one origin &&
123 git -C shallow12 log --pretty=tformat:%s origin/master >actual &&
124 test_write_lines three two >expected &&
125 test_cmp expected actual
128 test_expect_success 'fetching deepen' '
129 test_create_repo shallow-deepen &&
131 cd shallow-deepen &&
132 test_commit one &&
133 test_commit two &&
134 test_commit three &&
135 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" &&
136 git clone --depth 1 $HTTPD_URL/smart/shallow-deepen.git deepen &&
137 mv "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" .git &&
138 test_commit four &&
139 git -C deepen log --pretty=tformat:%s master >actual &&
140 echo three >expected &&
141 test_cmp expected actual &&
142 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" &&
143 git -C deepen fetch --deepen=1 &&
144 git -C deepen log --pretty=tformat:%s origin/master >actual &&
145 cat >expected <<-\EOF &&
146 four
147 three
150 test_cmp expected actual
154 test_done