Merge branch 'ab/ci-updates'
[git/debian.git] / t / t5539-fetch-http-shallow.sh
blob3ea75d34ca0e7ae82b6c1c5e88fdd1f8594c036e
1 #!/bin/sh
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-lib.sh
9 . "$TEST_DIRECTORY"/lib-httpd.sh
10 start_httpd
12 commit() {
13 echo "$1" >tracked &&
14 git add tracked &&
15 test_tick &&
16 git commit -m "$1"
19 test_expect_success 'setup shallow clone' '
20 test_tick=1500000000 &&
21 commit 1 &&
22 commit 2 &&
23 commit 3 &&
24 commit 4 &&
25 commit 5 &&
26 commit 6 &&
27 commit 7 &&
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 &&
36 cd clone &&
37 git fsck &&
38 git log --format=%s origin/main >actual &&
39 cat <<EOF >expect &&
45 EOF
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' '
55 cd shallow &&
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 ||
64 exit 1
65 done &&
66 git checkout main &&
67 test_commit new &&
68 git push "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" main
69 ) &&
71 cd clone &&
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 &&
87 cd 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 &&
103 three
106 test_cmp expected actual
109 test_expect_success 'shallow clone exclude tag two' '
110 test_create_repo shallow-exclude &&
112 cd shallow-exclude &&
113 test_commit one &&
114 test_commit two &&
115 test_commit three &&
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 &&
134 cd shallow-deepen &&
135 test_commit one &&
136 test_commit two &&
137 test_commit three &&
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 &&
141 test_commit four &&
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 &&
149 four
150 three
153 test_cmp expected actual
157 test_done