3 test_description
='fetch/clone from a shallow clone over http'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
10 .
"$TEST_DIRECTORY"/lib-httpd.sh
20 test_expect_success
'setup shallow clone' '
21 test_tick=1500000000 &&
29 git clone --no-local --depth=5 .git shallow &&
30 git config --global transfer.fsckObjects true
33 test_expect_success
'clone http repository' '
34 git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
35 git clone $HTTPD_URL/smart/repo.git clone &&
39 git log --format=%s origin/main >actual &&
47 test_cmp expect actual
51 # This test is tricky. We need large enough "have"s that fetch-pack
52 # will put pkt-flush in between. Then we need a "have" the server
53 # does not have, it'll send "ACK %s ready"
54 test_expect_success
'no shallow lines after receiving ACK ready' '
57 for i in $(test_seq 15)
59 git checkout --orphan unrelated$i &&
60 test_commit unrelated$i &&
61 git push -q "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
62 refs/heads/unrelated$i:refs/heads/unrelated$i &&
63 git push -q ../clone/.git \
64 refs/heads/unrelated$i:refs/heads/unrelated$i ||
69 git push "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" main
73 git checkout --orphan newnew &&
74 test_tick=1400000000 &&
75 test_commit new-too &&
76 # NEEDSWORK: If the overspecification of the expected result is reduced, we
77 # might be able to run this test in all protocol versions.
78 GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION=0 \
79 git fetch --depth=2 &&
80 grep "fetch-pack< ACK .* ready" ../trace &&
81 ! grep "fetch-pack> done" ../trace
85 test_expect_success
'clone shallow since ...' '
86 test_create_repo shallow-since &&
89 GIT_COMMITTER_DATE="100000000 +0700" git commit --allow-empty -m one &&
90 GIT_COMMITTER_DATE="200000000 +0700" git commit --allow-empty -m two &&
91 GIT_COMMITTER_DATE="300000000 +0700" git commit --allow-empty -m three &&
92 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-since.git" &&
93 git clone --shallow-since "300000000 +0700" $HTTPD_URL/smart/shallow-since.git ../shallow11 &&
94 git -C ../shallow11 log --pretty=tformat:%s HEAD >actual &&
95 echo three >expected &&
96 test_cmp expected actual
100 test_expect_success
'fetch shallow since ...' '
101 git -C shallow11 fetch --shallow-since "200000000 +0700" origin &&
102 git -C shallow11 log --pretty=tformat:%s origin/main >actual &&
103 cat >expected <<-\EOF &&
107 test_cmp expected actual
110 test_expect_success
'shallow clone exclude tag two' '
111 test_create_repo shallow-exclude &&
113 cd shallow-exclude &&
117 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-exclude.git" &&
118 git clone --shallow-exclude two $HTTPD_URL/smart/shallow-exclude.git ../shallow12 &&
119 git -C ../shallow12 log --pretty=tformat:%s HEAD >actual &&
120 echo three >expected &&
121 test_cmp expected actual
125 test_expect_success
'fetch exclude tag one' '
126 git -C shallow12 fetch --shallow-exclude one origin &&
127 git -C shallow12 log --pretty=tformat:%s origin/main >actual &&
128 test_write_lines three two >expected &&
129 test_cmp expected actual
132 test_expect_success
'fetching deepen' '
133 test_create_repo shallow-deepen &&
139 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" &&
140 git clone --depth 1 $HTTPD_URL/smart/shallow-deepen.git deepen &&
141 mv "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" .git &&
143 git -C deepen log --pretty=tformat:%s main >actual &&
144 echo three >expected &&
145 test_cmp expected actual &&
146 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" &&
147 git -C deepen fetch --deepen=1 &&
148 git -C deepen log --pretty=tformat:%s origin/main >actual &&
149 cat >expected <<-\EOF &&
154 test_cmp expected actual