3 test_description
='fetch/clone from a shallow clone over http'
6 .
"$TEST_DIRECTORY"/lib-httpd.sh
16 test_expect_success
'setup shallow clone' '
17 test_tick=1500000000 &&
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 &&
35 git log --format=%s origin/master >actual &&
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' '
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 ||
63 git checkout master &&
65 git push "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" master
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 &&
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 &&
103 test_cmp expected actual
106 test_expect_success
'shallow clone exclude tag two' '
107 test_create_repo shallow-exclude &&
109 cd shallow-exclude &&
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 &&
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 &&
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 &&
150 test_cmp expected actual