ci: fix setup of custom path for GitLab CI
[alt-git.git] / t / t4067-diff-partial-clone.sh
blob7af3a08862dec8a17b113191a3dbea56b0995cd3
1 #!/bin/sh
3 test_description='behavior of diff when reading objects in a partial clone'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'git show batches blobs' '
9 test_when_finished "rm -rf server client trace" &&
11 test_create_repo server &&
12 echo a >server/a &&
13 echo b >server/b &&
14 git -C server add a b &&
15 git -C server commit -m x &&
17 test_config -C server uploadpack.allowfilter 1 &&
18 test_config -C server uploadpack.allowanysha1inwant 1 &&
19 git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client &&
21 # Ensure that there is exactly 1 negotiation by checking that there is
22 # only 1 "done" line sent. ("done" marks the end of negotiation.)
23 GIT_TRACE_PACKET="$(pwd)/trace" git -C client show HEAD &&
24 grep "fetch> done" trace >done_lines &&
25 test_line_count = 1 done_lines
28 test_expect_success 'diff batches blobs' '
29 test_when_finished "rm -rf server client trace" &&
31 test_create_repo server &&
32 echo a >server/a &&
33 echo b >server/b &&
34 git -C server add a b &&
35 git -C server commit -m x &&
36 echo c >server/c &&
37 echo d >server/d &&
38 git -C server add c d &&
39 git -C server commit -m x &&
41 test_config -C server uploadpack.allowfilter 1 &&
42 test_config -C server uploadpack.allowanysha1inwant 1 &&
43 git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client &&
45 # Ensure that there is exactly 1 negotiation by checking that there is
46 # only 1 "done" line sent. ("done" marks the end of negotiation.)
47 GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff HEAD^ HEAD &&
48 grep "fetch> done" trace >done_lines &&
49 test_line_count = 1 done_lines
52 test_expect_success 'diff skips same-OID blobs' '
53 test_when_finished "rm -rf server client trace" &&
55 test_create_repo server &&
56 echo a >server/a &&
57 echo b >server/b &&
58 git -C server add a b &&
59 git -C server commit -m x &&
60 echo another-a >server/a &&
61 git -C server add a &&
62 git -C server commit -m x &&
64 test_config -C server uploadpack.allowfilter 1 &&
65 test_config -C server uploadpack.allowanysha1inwant 1 &&
66 git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client &&
68 echo a | git hash-object --stdin >hash-old-a &&
69 echo another-a | git hash-object --stdin >hash-new-a &&
70 echo b | git hash-object --stdin >hash-b &&
72 # Ensure that only a and another-a are fetched.
73 GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff HEAD^ HEAD &&
74 grep "want $(cat hash-old-a)" trace &&
75 grep "want $(cat hash-new-a)" trace &&
76 ! grep "want $(cat hash-b)" trace
79 test_expect_success 'when fetching missing objects, diff skips GITLINKs' '
80 test_when_finished "rm -rf sub server client trace" &&
81 test_config_global protocol.file.allow always &&
83 test_create_repo sub &&
84 test_commit -C sub first &&
86 test_create_repo server &&
87 echo a >server/a &&
88 git -C server add a &&
89 git -C server submodule add "file://$(pwd)/sub" &&
90 git -C server commit -m x &&
92 test_commit -C server/sub second &&
93 echo another-a >server/a &&
94 git -C server add a sub &&
95 git -C server commit -m x &&
97 test_config -C server uploadpack.allowfilter 1 &&
98 test_config -C server uploadpack.allowanysha1inwant 1 &&
99 git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client &&
101 echo a | git hash-object --stdin >hash-old-a &&
102 echo another-a | git hash-object --stdin >hash-new-a &&
104 # Ensure that a and another-a are fetched, and check (by successful
105 # execution of the diff) that no invalid OIDs are sent.
106 GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff HEAD^ HEAD &&
107 grep "want $(cat hash-old-a)" trace &&
108 grep "want $(cat hash-new-a)" trace
111 test_expect_success 'diff with rename detection batches blobs' '
112 test_when_finished "rm -rf server client trace" &&
114 test_create_repo server &&
115 echo a >server/a &&
116 printf "b\nb\nb\nb\nb\n" >server/b &&
117 git -C server add a b &&
118 git -C server commit -m x &&
119 rm server/b &&
120 printf "b\nb\nb\nb\nbX\n" >server/c &&
121 git -C server add c &&
122 git -C server commit -a -m x &&
124 test_config -C server uploadpack.allowfilter 1 &&
125 test_config -C server uploadpack.allowanysha1inwant 1 &&
126 git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client &&
128 # Ensure that there is exactly 1 negotiation by checking that there is
129 # only 1 "done" line sent. ("done" marks the end of negotiation.)
130 GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff --raw -M HEAD^ HEAD >out &&
131 grep ":100644 100644.*R[0-9][0-9][0-9].*b.*c" out &&
132 grep "fetch> done" trace >done_lines &&
133 test_line_count = 1 done_lines
136 test_expect_success 'diff does not fetch anything if inexact rename detection is not needed' '
137 test_when_finished "rm -rf server client trace" &&
139 test_create_repo server &&
140 echo a >server/a &&
141 printf "b\nb\nb\nb\nb\n" >server/b &&
142 git -C server add a b &&
143 git -C server commit -m x &&
144 mv server/b server/c &&
145 git -C server add c &&
146 git -C server commit -a -m x &&
148 test_config -C server uploadpack.allowfilter 1 &&
149 test_config -C server uploadpack.allowanysha1inwant 1 &&
150 git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client &&
152 # Ensure no fetches.
153 GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff --raw -M HEAD^ HEAD &&
154 test_path_is_missing trace
157 test_expect_success 'diff --break-rewrites fetches only if necessary, and batches blobs if it does' '
158 test_when_finished "rm -rf server client trace" &&
160 test_create_repo server &&
161 echo a >server/a &&
162 printf "b\nb\nb\nb\nb\n" >server/b &&
163 git -C server add a b &&
164 git -C server commit -m x &&
165 printf "c\nc\nc\nc\nc\n" >server/b &&
166 git -C server commit -a -m x &&
168 test_config -C server uploadpack.allowfilter 1 &&
169 test_config -C server uploadpack.allowanysha1inwant 1 &&
170 git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client &&
172 # Ensure no fetches.
173 GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff --raw -M HEAD^ HEAD &&
174 test_path_is_missing trace &&
176 # But with --break-rewrites, ensure that there is exactly 1 negotiation
177 # by checking that there is only 1 "done" line sent. ("done" marks the
178 # end of negotiation.)
179 GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff --break-rewrites --raw -M HEAD^ HEAD &&
180 grep "fetch> done" trace >done_lines &&
181 test_line_count = 1 done_lines
184 test_done