]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5539-fetch-http-shallow.sh
Merge branch 'ea/blame-use-oideq'
[thirdparty/git.git] / t / t5539-fetch-http-shallow.sh
CommitLineData
0232852b
NTND
1#!/bin/sh
2
3test_description='fetch/clone from a shallow clone over http'
4
5. ./test-lib.sh
0232852b
NTND
6. "$TEST_DIRECTORY"/lib-httpd.sh
7start_httpd
8
9commit() {
10 echo "$1" >tracked &&
11 git add tracked &&
f4eec0ba 12 test_tick &&
0232852b
NTND
13 git commit -m "$1"
14}
15
16test_expect_success 'setup shallow clone' '
f4eec0ba 17 test_tick=1500000000 &&
0232852b
NTND
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
27'
28
29test_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 &&
32 (
33 cd clone &&
34 git fsck &&
35 git log --format=%s origin/master >actual &&
36 cat <<EOF >expect &&
377
386
395
404
413
42EOF
43 test_cmp expect actual
44 )
45'
46
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"
50test_expect_success 'no shallow lines after receiving ACK ready' '
51 (
52 cd shallow &&
53 for i in $(test_seq 15)
54 do
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 ) &&
67 (
68 cd clone &&
69 git checkout --orphan newnew &&
f4eec0ba 70 test_tick=1400000000 &&
0232852b 71 test_commit new-too &&
d790ee17
JT
72 # NEEDSWORK: If the overspecification of the expected result is reduced, we
73 # might be able to run this test in all protocol versions.
8a1b0978 74 GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION=0 \
d790ee17 75 git fetch --depth=2 &&
0232852b
NTND
76 grep "fetch-pack< ACK .* ready" ../trace &&
77 ! grep "fetch-pack> done" ../trace
78 )
79'
80
6d43a0ce
NTND
81test_expect_success 'clone shallow since ...' '
82 test_create_repo shallow-since &&
83 (
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
93 )
94'
95
96test_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
101 two
102 EOF
103 test_cmp expected actual
104'
105
cdc37277
NTND
106test_expect_success 'shallow clone exclude tag two' '
107 test_create_repo shallow-exclude &&
108 (
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
118 )
119'
120
121test_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
126'
127
cccf74e2
NTND
128test_expect_success 'fetching deepen' '
129 test_create_repo shallow-deepen &&
130 (
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
148 two
149 EOF
150 test_cmp expected actual
151 )
152'
153
0232852b 154test_done