3 test_description='fetch/clone from a shallow clone over http'
6 . "$TEST_DIRECTORY"/lib-httpd.sh
15 test_expect_success 'setup shallow clone' '
23 git clone --no-local --depth=5 .git shallow &&
24 git config --global transfer.fsckObjects true
27 test_expect_success 'clone http repository' '
28 git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
29 git clone $HTTPD_URL/smart/repo.git clone &&
33 git log --format=%s origin/master >actual &&
41 test_cmp expect actual
45 # This test is tricky. We need large enough "have"s that fetch-pack
46 # will put pkt-flush in between. Then we need a "have" the server
47 # does not have, it'll send "ACK %s ready"
48 test_expect_success 'no shallow lines after receiving ACK ready' '
52 for i in $(test_seq 15)
54 git checkout --orphan unrelated$i &&
55 test_commit unrelated$i &&
56 git push -q "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
57 refs/heads/unrelated$i:refs/heads/unrelated$i &&
58 git push -q ../clone/.git \
59 refs/heads/unrelated$i:refs/heads/unrelated$i ||
62 git checkout master &&
64 git push "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" master
68 git checkout --orphan newnew &&
69 test_commit new-too &&
70 # NEEDSWORK: If the overspecification of the expected result is reduced, we
71 # might be able to run this test in all protocol versions.
72 GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION= \
73 git fetch --depth=2 &&
74 grep "fetch-pack< ACK .* ready" ../trace &&
75 ! grep "fetch-pack> done" ../trace
79 test_expect_success 'clone shallow since ...' '
80 test_create_repo shallow-since &&
83 GIT_COMMITTER_DATE="100000000 +0700" git commit --allow-empty -m one &&
84 GIT_COMMITTER_DATE="200000000 +0700" git commit --allow-empty -m two &&
85 GIT_COMMITTER_DATE="300000000 +0700" git commit --allow-empty -m three &&
86 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-since.git" &&
87 git clone --shallow-since "300000000 +0700" $HTTPD_URL/smart/shallow-since.git ../shallow11 &&
88 git -C ../shallow11 log --pretty=tformat:%s HEAD >actual &&
89 echo three >expected &&
90 test_cmp expected actual
94 test_expect_success 'fetch shallow since ...' '
95 git -C shallow11 fetch --shallow-since "200000000 +0700" origin &&
96 git -C shallow11 log --pretty=tformat:%s origin/master >actual &&
97 cat >expected <<-\EOF &&
101 test_cmp expected actual
104 test_expect_success 'shallow clone exclude tag two' '
105 test_create_repo shallow-exclude &&
107 cd shallow-exclude &&
111 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-exclude.git" &&
112 git clone --shallow-exclude two $HTTPD_URL/smart/shallow-exclude.git ../shallow12 &&
113 git -C ../shallow12 log --pretty=tformat:%s HEAD >actual &&
114 echo three >expected &&
115 test_cmp expected actual
119 test_expect_success 'fetch exclude tag one' '
120 git -C shallow12 fetch --shallow-exclude one origin &&
121 git -C shallow12 log --pretty=tformat:%s origin/master >actual &&
122 test_write_lines three two >expected &&
123 test_cmp expected actual
126 test_expect_success 'fetching deepen' '
127 test_create_repo shallow-deepen &&
133 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" &&
134 git clone --depth 1 $HTTPD_URL/smart/shallow-deepen.git deepen &&
135 mv "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" .git &&
137 git -C deepen log --pretty=tformat:%s master >actual &&
138 echo three >expected &&
139 test_cmp expected actual &&
140 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" &&
141 git -C deepen fetch --deepen=1 &&
142 git -C deepen log --pretty=tformat:%s origin/master >actual &&
143 cat >expected <<-\EOF &&
148 test_cmp expected actual