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
9 . "$TEST_DIRECTORY"/lib-httpd.sh
19 test_expect_success 'setup shallow clone' '
20 test_tick=1500000000 &&
28 git clone --no-local --depth=5 .git shallow &&
29 git config --global transfer.fsckObjects true
32 test_expect_success 'clone http repository' '
33 git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
34 git clone $HTTPD_URL/smart/repo.git clone &&
38 git log --format=%s origin/main >actual &&
46 test_cmp expect actual
50 # This test is tricky. We need large enough "have"s that fetch-pack
51 # will put pkt-flush in between. Then we need a "have" the server
52 # does not have, it'll send "ACK %s ready"
53 test_expect_success 'no shallow lines after receiving ACK ready' '
56 for i in $(test_seq 15)
58 git checkout --orphan unrelated$i &&
59 test_commit unrelated$i &&
60 git push -q "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
61 refs/heads/unrelated$i:refs/heads/unrelated$i &&
62 git push -q ../clone/.git \
63 refs/heads/unrelated$i:refs/heads/unrelated$i ||
68 git push "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" main
72 git checkout --orphan newnew &&
73 test_tick=1400000000 &&
74 test_commit new-too &&
75 # NEEDSWORK: If the overspecification of the expected result is reduced, we
76 # might be able to run this test in all protocol versions.
77 GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION=0 \
78 git fetch --depth=2 &&
79 grep "fetch-pack< ACK .* ready" ../trace &&
80 ! grep "fetch-pack> done" ../trace
84 test_expect_success 'clone shallow since ...' '
85 test_create_repo shallow-since &&
88 GIT_COMMITTER_DATE="100000000 +0700" git commit --allow-empty -m one &&
89 GIT_COMMITTER_DATE="200000000 +0700" git commit --allow-empty -m two &&
90 GIT_COMMITTER_DATE="300000000 +0700" git commit --allow-empty -m three &&
91 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-since.git" &&
92 git clone --shallow-since "300000000 +0700" $HTTPD_URL/smart/shallow-since.git ../shallow11 &&
93 git -C ../shallow11 log --pretty=tformat:%s HEAD >actual &&
94 echo three >expected &&
95 test_cmp expected actual
99 test_expect_success 'fetch shallow since ...' '
100 git -C shallow11 fetch --shallow-since "200000000 +0700" origin &&
101 git -C shallow11 log --pretty=tformat:%s origin/main >actual &&
102 cat >expected <<-\EOF &&
106 test_cmp expected actual
109 test_expect_success 'shallow clone exclude tag two' '
110 test_create_repo shallow-exclude &&
112 cd shallow-exclude &&
116 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-exclude.git" &&
117 git clone --shallow-exclude two $HTTPD_URL/smart/shallow-exclude.git ../shallow12 &&
118 git -C ../shallow12 log --pretty=tformat:%s HEAD >actual &&
119 echo three >expected &&
120 test_cmp expected actual
124 test_expect_success 'fetch exclude tag one' '
125 git -C shallow12 fetch --shallow-exclude one origin &&
126 git -C shallow12 log --pretty=tformat:%s origin/main >actual &&
127 test_write_lines three two >expected &&
128 test_cmp expected actual
131 test_expect_success 'fetching deepen' '
132 test_create_repo shallow-deepen &&
138 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" &&
139 git clone --depth 1 $HTTPD_URL/smart/shallow-deepen.git deepen &&
140 mv "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" .git &&
142 git -C deepen log --pretty=tformat:%s main >actual &&
143 echo three >expected &&
144 test_cmp expected actual &&
145 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" &&
146 git -C deepen fetch --deepen=1 &&
147 git -C deepen log --pretty=tformat:%s origin/main >actual &&
148 cat >expected <<-\EOF &&
153 test_cmp expected actual