]>
Commit | Line | Data |
---|---|---|
8884cf15 TR |
1 | #!/bin/sh |
2 | ||
3 | test_description='range-diff tests' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | # Note that because of the range-diff's heuristics, test_commit does more | |
8 | # harm than good. We need some real history. | |
9 | ||
10 | test_expect_success 'setup' ' | |
3a6e48e9 | 11 | git fast-import <"$TEST_DIRECTORY"/t3206/history.export && |
79f3950d | 12 | test_oid_cache <<-\EOF |
b561edd2 | 13 | # topic |
14 | t1 sha1:4de457d | |
15 | t2 sha1:fccce22 | |
16 | t3 sha1:147e64e | |
17 | t4 sha1:a63e992 | |
18 | t1 sha256:b89f8b9 | |
19 | t2 sha256:5f12aad | |
20 | t3 sha256:ea8b273 | |
21 | t4 sha256:14b7336 | |
22 | ||
23 | # unmodified | |
24 | u1 sha1:35b9b25 | |
25 | u2 sha1:de345ab | |
26 | u3 sha1:9af6654 | |
27 | u4 sha1:2901f77 | |
28 | u1 sha256:e3731be | |
29 | u2 sha256:14fadf8 | |
30 | u3 sha256:736c4bc | |
31 | u4 sha256:673e77d | |
32 | ||
33 | # reordered | |
34 | r1 sha1:aca177a | |
35 | r2 sha1:14ad629 | |
36 | r3 sha1:ee58208 | |
37 | r4 sha1:307b27a | |
38 | r1 sha256:f59d3aa | |
39 | r2 sha256:fb261a8 | |
40 | r3 sha256:cb2649b | |
41 | r4 sha256:958577e | |
42 | ||
43 | # removed (deleted) | |
44 | d1 sha1:7657159 | |
45 | d2 sha1:43d84d3 | |
46 | d3 sha1:a740396 | |
47 | d1 sha256:e312513 | |
48 | d2 sha256:eb19258 | |
49 | d3 sha256:1ccb3c1 | |
50 | ||
51 | # added | |
52 | a1 sha1:2716022 | |
53 | a2 sha1:b62accd | |
54 | a3 sha1:df46cfa | |
55 | a4 sha1:3e64548 | |
56 | a5 sha1:12b4063 | |
57 | a1 sha256:d724f4d | |
58 | a2 sha256:1de7762 | |
59 | a3 sha256:e159431 | |
60 | a4 sha256:b3e483c | |
61 | a5 sha256:90866a7 | |
62 | ||
63 | # rebased | |
64 | b1 sha1:cc9c443 | |
65 | b2 sha1:c5d9641 | |
66 | b3 sha1:28cc2b6 | |
67 | b4 sha1:5628ab7 | |
68 | b5 sha1:a31b12e | |
69 | b1 sha256:a1a8717 | |
70 | b2 sha256:20a5862 | |
71 | b3 sha256:587172a | |
72 | b4 sha256:2721c5d | |
73 | b5 sha256:7b57864 | |
74 | ||
75 | # changed | |
76 | c1 sha1:a4b3333 | |
77 | c2 sha1:f51d370 | |
78 | c3 sha1:0559556 | |
79 | c4 sha1:d966c5c | |
80 | c1 sha256:f8c2b9d | |
81 | c2 sha256:3fb6318 | |
82 | c3 sha256:168ab68 | |
83 | c4 sha256:3526539 | |
84 | ||
85 | # changed-message | |
86 | m1 sha1:f686024 | |
87 | m2 sha1:4ab067d | |
88 | m3 sha1:b9cb956 | |
89 | m4 sha1:8add5f1 | |
90 | m1 sha256:31e6281 | |
91 | m2 sha256:a06bf1b | |
92 | m3 sha256:82dc654 | |
93 | m4 sha256:48470c5 | |
94 | ||
95 | # renamed | |
96 | n1 sha1:f258d75 | |
97 | n2 sha1:017b62d | |
98 | n3 sha1:3ce7af6 | |
99 | n4 sha1:1e6226b | |
100 | n1 sha256:ad52114 | |
101 | n2 sha256:3b54c8f | |
102 | n3 sha256:3b0a644 | |
103 | n4 sha256:e461653 | |
104 | ||
105 | # added and removed | |
106 | s1 sha1:096b1ba | |
107 | s2 sha1:d92e698 | |
108 | s3 sha1:9a1db4d | |
109 | s4 sha1:fea3b5c | |
110 | s1 sha256:a7f9134 | |
111 | s2 sha256:b4c2580 | |
112 | s3 sha256:1d62aa2 | |
113 | s4 sha256:48160e8 | |
114 | ||
115 | # Empty delimiter (included so lines match neatly) | |
116 | __ sha1:------- | |
117 | __ sha256:------- | |
118 | EOF | |
8884cf15 TR |
119 | ' |
120 | ||
121 | test_expect_success 'simple A..B A..C (unmodified)' ' | |
122 | git range-diff --no-color master..topic master..unmodified \ | |
123 | >actual && | |
75c5aa07 | 124 | cat >expect <<-EOF && |
b561edd2 | 125 | 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ |
126 | 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/ | |
127 | 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/ | |
128 | 4: $(test_oid t4) = 4: $(test_oid u4) s/12/B/ | |
8884cf15 | 129 | EOF |
75c5aa07 | 130 | test_cmp expect actual |
8884cf15 TR |
131 | ' |
132 | ||
133 | test_expect_success 'simple B...C (unmodified)' ' | |
134 | git range-diff --no-color topic...unmodified >actual && | |
75c5aa07 DL |
135 | # same "expect" as above |
136 | test_cmp expect actual | |
8884cf15 TR |
137 | ' |
138 | ||
139 | test_expect_success 'simple A B C (unmodified)' ' | |
140 | git range-diff --no-color master topic unmodified >actual && | |
75c5aa07 DL |
141 | # same "expect" as above |
142 | test_cmp expect actual | |
8884cf15 TR |
143 | ' |
144 | ||
145 | test_expect_success 'trivial reordering' ' | |
146 | git range-diff --no-color master topic reordered >actual && | |
75c5aa07 | 147 | cat >expect <<-EOF && |
b561edd2 | 148 | 1: $(test_oid t1) = 1: $(test_oid r1) s/5/A/ |
149 | 3: $(test_oid t3) = 2: $(test_oid r2) s/11/B/ | |
150 | 4: $(test_oid t4) = 3: $(test_oid r3) s/12/B/ | |
151 | 2: $(test_oid t2) = 4: $(test_oid r4) s/4/A/ | |
8884cf15 | 152 | EOF |
75c5aa07 | 153 | test_cmp expect actual |
8884cf15 TR |
154 | ' |
155 | ||
156 | test_expect_success 'removed a commit' ' | |
157 | git range-diff --no-color master topic removed >actual && | |
75c5aa07 | 158 | cat >expect <<-EOF && |
b561edd2 | 159 | 1: $(test_oid t1) = 1: $(test_oid d1) s/5/A/ |
160 | 2: $(test_oid t2) < -: $(test_oid __) s/4/A/ | |
161 | 3: $(test_oid t3) = 2: $(test_oid d2) s/11/B/ | |
162 | 4: $(test_oid t4) = 3: $(test_oid d3) s/12/B/ | |
8884cf15 | 163 | EOF |
75c5aa07 | 164 | test_cmp expect actual |
8884cf15 TR |
165 | ' |
166 | ||
167 | test_expect_success 'added a commit' ' | |
168 | git range-diff --no-color master topic added >actual && | |
75c5aa07 | 169 | cat >expect <<-EOF && |
b561edd2 | 170 | 1: $(test_oid t1) = 1: $(test_oid a1) s/5/A/ |
171 | 2: $(test_oid t2) = 2: $(test_oid a2) s/4/A/ | |
172 | -: $(test_oid __) > 3: $(test_oid a3) s/6/A/ | |
173 | 3: $(test_oid t3) = 4: $(test_oid a4) s/11/B/ | |
174 | 4: $(test_oid t4) = 5: $(test_oid a5) s/12/B/ | |
8884cf15 | 175 | EOF |
75c5aa07 | 176 | test_cmp expect actual |
8884cf15 TR |
177 | ' |
178 | ||
179 | test_expect_success 'new base, A B C' ' | |
180 | git range-diff --no-color master topic rebased >actual && | |
75c5aa07 | 181 | cat >expect <<-EOF && |
b561edd2 | 182 | 1: $(test_oid t1) = 1: $(test_oid b1) s/5/A/ |
183 | 2: $(test_oid t2) = 2: $(test_oid b2) s/4/A/ | |
184 | 3: $(test_oid t3) = 3: $(test_oid b3) s/11/B/ | |
185 | 4: $(test_oid t4) = 4: $(test_oid b4) s/12/B/ | |
8884cf15 | 186 | EOF |
75c5aa07 | 187 | test_cmp expect actual |
8884cf15 TR |
188 | ' |
189 | ||
190 | test_expect_success 'new base, B...C' ' | |
191 | # this syntax includes the commits from master! | |
192 | git range-diff --no-color topic...rebased >actual && | |
75c5aa07 | 193 | cat >expect <<-EOF && |
b561edd2 | 194 | -: $(test_oid __) > 1: $(test_oid b5) unrelated |
195 | 1: $(test_oid t1) = 2: $(test_oid b1) s/5/A/ | |
196 | 2: $(test_oid t2) = 3: $(test_oid b2) s/4/A/ | |
197 | 3: $(test_oid t3) = 4: $(test_oid b3) s/11/B/ | |
198 | 4: $(test_oid t4) = 5: $(test_oid b4) s/12/B/ | |
8884cf15 | 199 | EOF |
75c5aa07 | 200 | test_cmp expect actual |
8884cf15 TR |
201 | ' |
202 | ||
203 | test_expect_success 'changed commit' ' | |
204 | git range-diff --no-color topic...changed >actual && | |
75c5aa07 | 205 | cat >expect <<-EOF && |
b561edd2 | 206 | 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/ |
207 | 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/ | |
208 | 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/ | |
499352c2 | 209 | @@ file: A |
8884cf15 TR |
210 | 9 |
211 | 10 | |
212 | -11 | |
213 | -+B | |
214 | ++BB | |
215 | 12 | |
216 | 13 | |
217 | 14 | |
b561edd2 | 218 | 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/ |
499352c2 | 219 | @@ file |
444e0969 | 220 | @@ file: A |
8884cf15 TR |
221 | 9 |
222 | 10 | |
223 | - B | |
224 | + BB | |
225 | -12 | |
226 | +B | |
227 | 13 | |
228 | EOF | |
75c5aa07 | 229 | test_cmp expect actual |
8884cf15 TR |
230 | ' |
231 | ||
4624185a ÆAB |
232 | test_expect_success 'changed commit with --no-patch diff option' ' |
233 | git range-diff --no-color --no-patch topic...changed >actual && | |
75c5aa07 | 234 | cat >expect <<-EOF && |
b561edd2 | 235 | 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/ |
236 | 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/ | |
237 | 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/ | |
238 | 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/ | |
4624185a | 239 | EOF |
75c5aa07 | 240 | test_cmp expect actual |
4624185a ÆAB |
241 | ' |
242 | ||
243 | test_expect_success 'changed commit with --stat diff option' ' | |
4624185a | 244 | git range-diff --no-color --stat topic...changed >actual && |
75c5aa07 | 245 | cat >expect <<-EOF && |
b561edd2 | 246 | 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/ |
4624185a ÆAB |
247 | a => b | 0 |
248 | 1 file changed, 0 insertions(+), 0 deletions(-) | |
b561edd2 | 249 | 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/ |
4624185a ÆAB |
250 | a => b | 0 |
251 | 1 file changed, 0 insertions(+), 0 deletions(-) | |
b561edd2 | 252 | 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/ |
4624185a ÆAB |
253 | a => b | 0 |
254 | 1 file changed, 0 insertions(+), 0 deletions(-) | |
b561edd2 | 255 | 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/ |
4624185a ÆAB |
256 | a => b | 0 |
257 | 1 file changed, 0 insertions(+), 0 deletions(-) | |
4624185a | 258 | EOF |
75c5aa07 | 259 | test_cmp expect actual |
4624185a ÆAB |
260 | ' |
261 | ||
0e573e8f LDM |
262 | test_expect_success 'changed commit with sm config' ' |
263 | git range-diff --no-color --submodule=log topic...changed >actual && | |
75c5aa07 | 264 | cat >expect <<-EOF && |
b561edd2 | 265 | 1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/ |
266 | 2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/ | |
267 | 3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/ | |
499352c2 | 268 | @@ file: A |
0e573e8f LDM |
269 | 9 |
270 | 10 | |
271 | -11 | |
272 | -+B | |
273 | ++BB | |
274 | 12 | |
275 | 13 | |
276 | 14 | |
b561edd2 | 277 | 4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/ |
499352c2 | 278 | @@ file |
444e0969 | 279 | @@ file: A |
0e573e8f LDM |
280 | 9 |
281 | 10 | |
282 | - B | |
283 | + BB | |
284 | -12 | |
285 | +B | |
286 | 13 | |
287 | EOF | |
75c5aa07 | 288 | test_cmp expect actual |
0e573e8f LDM |
289 | ' |
290 | ||
b66885a3 TG |
291 | test_expect_success 'renamed file' ' |
292 | git range-diff --no-color --submodule=log topic...renamed-file >actual && | |
75c5aa07 | 293 | sed s/Z/\ /g >expect <<-EOF && |
b561edd2 | 294 | 1: $(test_oid t1) = 1: $(test_oid n1) s/5/A/ |
295 | 2: $(test_oid t2) ! 2: $(test_oid n2) s/4/A/ | |
499352c2 | 296 | @@ Metadata |
b66885a3 TG |
297 | ZAuthor: Thomas Rast <trast@inf.ethz.ch> |
298 | Z | |
499352c2 | 299 | Z ## Commit message ## |
b66885a3 TG |
300 | - s/4/A/ |
301 | + s/4/A/ + rename file | |
302 | Z | |
303 | - ## file ## | |
304 | + ## file => renamed-file ## | |
305 | Z@@ | |
306 | Z 1 | |
307 | Z 2 | |
b561edd2 | 308 | 3: $(test_oid t3) ! 3: $(test_oid n3) s/11/B/ |
499352c2 TG |
309 | @@ Metadata |
310 | Z ## Commit message ## | |
b66885a3 TG |
311 | Z s/11/B/ |
312 | Z | |
313 | - ## file ## | |
444e0969 | 314 | -@@ file: A |
b66885a3 | 315 | + ## renamed-file ## |
444e0969 | 316 | +@@ renamed-file: A |
b66885a3 TG |
317 | Z 8 |
318 | Z 9 | |
444e0969 | 319 | Z 10 |
b561edd2 | 320 | 4: $(test_oid t4) ! 4: $(test_oid n4) s/12/B/ |
499352c2 TG |
321 | @@ Metadata |
322 | Z ## Commit message ## | |
b66885a3 TG |
323 | Z s/12/B/ |
324 | Z | |
325 | - ## file ## | |
444e0969 | 326 | -@@ file: A |
b66885a3 | 327 | + ## renamed-file ## |
444e0969 | 328 | +@@ renamed-file: A |
b66885a3 TG |
329 | Z 9 |
330 | Z 10 | |
444e0969 | 331 | Z B |
b66885a3 | 332 | EOF |
75c5aa07 | 333 | test_cmp expect actual |
b66885a3 TG |
334 | ' |
335 | ||
2b6a9b13 TG |
336 | test_expect_success 'file with mode only change' ' |
337 | git range-diff --no-color --submodule=log topic...mode-only-change >actual && | |
75c5aa07 | 338 | sed s/Z/\ /g >expect <<-EOF && |
2b6a9b13 TG |
339 | 1: fccce22 ! 1: 4d39cb3 s/4/A/ |
340 | @@ Metadata | |
341 | ZAuthor: Thomas Rast <trast@inf.ethz.ch> | |
342 | Z | |
343 | Z ## Commit message ## | |
344 | - s/4/A/ | |
345 | + s/4/A/ + add other-file | |
346 | Z | |
347 | Z ## file ## | |
348 | Z@@ | |
349 | @@ file | |
350 | Z A | |
351 | Z 6 | |
352 | Z 7 | |
353 | + | |
354 | + ## other-file (new) ## | |
355 | 2: 147e64e ! 2: 26c107f s/11/B/ | |
356 | @@ Metadata | |
357 | ZAuthor: Thomas Rast <trast@inf.ethz.ch> | |
358 | Z | |
359 | Z ## Commit message ## | |
360 | - s/11/B/ | |
361 | + s/11/B/ + mode change other-file | |
362 | Z | |
363 | Z ## file ## | |
364 | Z@@ file: A | |
365 | @@ file: A | |
366 | Z 12 | |
367 | Z 13 | |
368 | Z 14 | |
369 | + | |
370 | + ## other-file (mode change 100644 => 100755) ## | |
371 | 3: a63e992 = 3: 4c1e0f5 s/12/B/ | |
372 | EOF | |
75c5aa07 | 373 | test_cmp expect actual |
2b6a9b13 TG |
374 | ' |
375 | ||
b66885a3 TG |
376 | test_expect_success 'file added and later removed' ' |
377 | git range-diff --no-color --submodule=log topic...added-removed >actual && | |
75c5aa07 | 378 | sed s/Z/\ /g >expect <<-EOF && |
b561edd2 | 379 | 1: $(test_oid t1) = 1: $(test_oid s1) s/5/A/ |
380 | 2: $(test_oid t2) ! 2: $(test_oid s2) s/4/A/ | |
499352c2 | 381 | @@ Metadata |
b66885a3 TG |
382 | ZAuthor: Thomas Rast <trast@inf.ethz.ch> |
383 | Z | |
499352c2 | 384 | Z ## Commit message ## |
b66885a3 TG |
385 | - s/4/A/ |
386 | + s/4/A/ + new-file | |
387 | Z | |
388 | Z ## file ## | |
389 | Z@@ | |
499352c2 | 390 | @@ file |
b66885a3 TG |
391 | Z A |
392 | Z 6 | |
393 | Z 7 | |
394 | + | |
395 | + ## new-file (new) ## | |
b561edd2 | 396 | 3: $(test_oid t3) ! 3: $(test_oid s3) s/11/B/ |
499352c2 | 397 | @@ Metadata |
b66885a3 TG |
398 | ZAuthor: Thomas Rast <trast@inf.ethz.ch> |
399 | Z | |
499352c2 | 400 | Z ## Commit message ## |
b66885a3 TG |
401 | - s/11/B/ |
402 | + s/11/B/ + remove file | |
403 | Z | |
404 | Z ## file ## | |
444e0969 | 405 | Z@@ file: A |
499352c2 | 406 | @@ file: A |
b66885a3 TG |
407 | Z 12 |
408 | Z 13 | |
409 | Z 14 | |
410 | + | |
411 | + ## new-file (deleted) ## | |
b561edd2 | 412 | 4: $(test_oid t4) = 4: $(test_oid s4) s/12/B/ |
b66885a3 | 413 | EOF |
75c5aa07 | 414 | test_cmp expect actual |
b66885a3 TG |
415 | ' |
416 | ||
51bbcda1 JH |
417 | test_expect_success 'no commits on one side' ' |
418 | git commit --amend -m "new message" && | |
419 | git range-diff master HEAD@{1} HEAD | |
420 | ' | |
421 | ||
8884cf15 TR |
422 | test_expect_success 'changed message' ' |
423 | git range-diff --no-color topic...changed-message >actual && | |
75c5aa07 | 424 | sed s/Z/\ /g >expect <<-EOF && |
b561edd2 | 425 | 1: $(test_oid t1) = 1: $(test_oid m1) s/5/A/ |
426 | 2: $(test_oid t2) ! 2: $(test_oid m2) s/4/A/ | |
499352c2 TG |
427 | @@ Metadata |
428 | Z ## Commit message ## | |
8884cf15 TR |
429 | Z s/4/A/ |
430 | Z | |
431 | + Also a silly comment here! | |
432 | + | |
b66885a3 TG |
433 | Z ## file ## |
434 | Z@@ | |
435 | Z 1 | |
b561edd2 | 436 | 3: $(test_oid t3) = 3: $(test_oid m3) s/11/B/ |
437 | 4: $(test_oid t4) = 4: $(test_oid m4) s/12/B/ | |
8884cf15 | 438 | EOF |
75c5aa07 | 439 | test_cmp expect actual |
8884cf15 TR |
440 | ' |
441 | ||
c5e64caa | 442 | test_expect_success 'dual-coloring' ' |
b561edd2 | 443 | sed -e "s|^:||" >expect <<-EOF && |
444 | :<YELLOW>1: $(test_oid c1) = 1: $(test_oid m1) s/5/A/<RESET> | |
445 | :<RED>2: $(test_oid c2) <RESET><YELLOW>!<RESET><GREEN> 2: $(test_oid m2)<RESET><YELLOW> s/4/A/<RESET> | |
499352c2 TG |
446 | : <REVERSE><CYAN>@@<RESET> <RESET>Metadata<RESET> |
447 | : ## Commit message ##<RESET> | |
c5e64caa SB |
448 | : s/4/A/<RESET> |
449 | : <RESET> | |
450 | : <REVERSE><GREEN>+<RESET><BOLD> Also a silly comment here!<RESET> | |
29ef759d | 451 | : <REVERSE><GREEN>+<RESET> |
b66885a3 TG |
452 | : ## file ##<RESET> |
453 | : <CYAN> @@<RESET> | |
454 | : 1<RESET> | |
b561edd2 | 455 | :<RED>3: $(test_oid c3) <RESET><YELLOW>!<RESET><GREEN> 3: $(test_oid m3)<RESET><YELLOW> s/11/B/<RESET> |
499352c2 | 456 | : <REVERSE><CYAN>@@<RESET> <RESET>file: A<RESET> |
c5e64caa SB |
457 | : 9<RESET> |
458 | : 10<RESET> | |
459 | : <RED> -11<RESET> | |
460 | : <REVERSE><RED>-<RESET><FAINT;GREEN>+BB<RESET> | |
461 | : <REVERSE><GREEN>+<RESET><BOLD;GREEN>+B<RESET> | |
462 | : 12<RESET> | |
463 | : 13<RESET> | |
464 | : 14<RESET> | |
b561edd2 | 465 | :<RED>4: $(test_oid c4) <RESET><YELLOW>!<RESET><GREEN> 4: $(test_oid m4)<RESET><YELLOW> s/12/B/<RESET> |
499352c2 | 466 | : <REVERSE><CYAN>@@<RESET> <RESET>file<RESET> |
444e0969 | 467 | : <CYAN> @@ file: A<RESET> |
c5e64caa SB |
468 | : 9<RESET> |
469 | : 10<RESET> | |
470 | : <REVERSE><RED>-<RESET><FAINT> BB<RESET> | |
471 | : <REVERSE><GREEN>+<RESET><BOLD> B<RESET> | |
472 | : <RED> -12<RESET> | |
473 | : <GREEN> +B<RESET> | |
474 | : 13<RESET> | |
475 | EOF | |
476 | git range-diff changed...changed-message --color --dual-color >actual.raw && | |
477 | test_decode_color >actual <actual.raw && | |
478 | test_cmp expect actual | |
479 | ' | |
480 | ||
2e6fd71a | 481 | for prev in topic master..topic |
31e2617a ES |
482 | do |
483 | test_expect_success "format-patch --range-diff=$prev" ' | |
ac0edf1f | 484 | git format-patch --cover-letter --range-diff=$prev \ |
31e2617a | 485 | master..unmodified >actual && |
ac0edf1f MÅ |
486 | test_when_finished "rm 000?-*" && |
487 | test_line_count = 5 actual && | |
488 | test_i18ngrep "^Range-diff:$" 0000-* && | |
489 | grep "= 1: .* s/5/A" 0000-* && | |
490 | grep "= 2: .* s/4/A" 0000-* && | |
491 | grep "= 3: .* s/11/B" 0000-* && | |
492 | grep "= 4: .* s/12/B" 0000-* | |
31e2617a ES |
493 | ' |
494 | done | |
495 | ||
cdc067c3 | 496 | test_expect_success 'format-patch --range-diff as commentary' ' |
ac0edf1f MÅ |
497 | git format-patch --range-diff=HEAD~1 HEAD~1 >actual && |
498 | test_when_finished "rm 0001-*" && | |
499 | test_line_count = 1 actual && | |
500 | test_i18ngrep "^Range-diff:$" 0001-* && | |
501 | grep "> 1: .* new message" 0001-* | |
cdc067c3 DS |
502 | ' |
503 | ||
937b76ed JS |
504 | test_expect_success 'range-diff overrides diff.noprefix internally' ' |
505 | git -c diff.noprefix=true range-diff HEAD^... | |
506 | ' | |
507 | ||
3bdbdfb7 DL |
508 | test_expect_success 'range-diff compares notes by default' ' |
509 | git notes add -m "topic note" topic && | |
510 | git notes add -m "unmodified note" unmodified && | |
511 | test_when_finished git notes remove topic unmodified && | |
512 | git range-diff --no-color master..topic master..unmodified \ | |
513 | >actual && | |
514 | sed s/Z/\ /g >expect <<-EOF && | |
515 | 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ | |
516 | 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/ | |
517 | 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/ | |
518 | 4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/ | |
9f726e1b | 519 | @@ Commit message |
3bdbdfb7 | 520 | Z |
9f726e1b DL |
521 | Z |
522 | Z ## Notes ## | |
3bdbdfb7 DL |
523 | - topic note |
524 | + unmodified note | |
525 | Z | |
526 | Z ## file ## | |
527 | Z@@ file: A | |
528 | EOF | |
529 | test_cmp expect actual | |
530 | ' | |
531 | ||
bd361918 DL |
532 | test_expect_success 'range-diff with --no-notes' ' |
533 | git notes add -m "topic note" topic && | |
534 | git notes add -m "unmodified note" unmodified && | |
535 | test_when_finished git notes remove topic unmodified && | |
536 | git range-diff --no-color --no-notes master..topic master..unmodified \ | |
537 | >actual && | |
538 | cat >expect <<-EOF && | |
539 | 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ | |
540 | 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/ | |
541 | 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/ | |
542 | 4: $(test_oid t4) = 4: $(test_oid u4) s/12/B/ | |
543 | EOF | |
544 | test_cmp expect actual | |
545 | ' | |
546 | ||
547 | test_expect_success 'range-diff with multiple --notes' ' | |
548 | git notes --ref=note1 add -m "topic note1" topic && | |
549 | git notes --ref=note1 add -m "unmodified note1" unmodified && | |
550 | test_when_finished git notes --ref=note1 remove topic unmodified && | |
551 | git notes --ref=note2 add -m "topic note2" topic && | |
552 | git notes --ref=note2 add -m "unmodified note2" unmodified && | |
553 | test_when_finished git notes --ref=note2 remove topic unmodified && | |
554 | git range-diff --no-color --notes=note1 --notes=note2 master..topic master..unmodified \ | |
555 | >actual && | |
556 | sed s/Z/\ /g >expect <<-EOF && | |
557 | 1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/ | |
558 | 2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/ | |
559 | 3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/ | |
560 | 4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/ | |
561 | @@ Commit message | |
562 | Z | |
563 | Z | |
564 | Z ## Notes (note1) ## | |
565 | - topic note1 | |
566 | + unmodified note1 | |
567 | Z | |
568 | Z | |
569 | Z ## Notes (note2) ## | |
570 | - topic note2 | |
571 | + unmodified note2 | |
572 | Z | |
573 | Z ## file ## | |
574 | Z@@ file: A | |
575 | EOF | |
576 | test_cmp expect actual | |
577 | ' | |
578 | ||
5b583e6a | 579 | test_expect_success 'format-patch --range-diff does not compare notes by default' ' |
3bdbdfb7 DL |
580 | git notes add -m "topic note" topic && |
581 | git notes add -m "unmodified note" unmodified && | |
582 | test_when_finished git notes remove topic unmodified && | |
583 | git format-patch --cover-letter --range-diff=$prev \ | |
584 | master..unmodified >actual && | |
585 | test_when_finished "rm 000?-*" && | |
586 | test_line_count = 5 actual && | |
587 | test_i18ngrep "^Range-diff:$" 0000-* && | |
588 | grep "= 1: .* s/5/A" 0000-* && | |
589 | grep "= 2: .* s/4/A" 0000-* && | |
590 | grep "= 3: .* s/11/B" 0000-* && | |
5b583e6a DL |
591 | grep "= 4: .* s/12/B" 0000-* && |
592 | ! grep "Notes" 0000-* && | |
593 | ! grep "note" 0000-* | |
594 | ' | |
595 | ||
596 | test_expect_success 'format-patch --range-diff with --no-notes' ' | |
597 | git notes add -m "topic note" topic && | |
598 | git notes add -m "unmodified note" unmodified && | |
599 | test_when_finished git notes remove topic unmodified && | |
600 | git format-patch --no-notes --cover-letter --range-diff=$prev \ | |
601 | master..unmodified >actual && | |
602 | test_when_finished "rm 000?-*" && | |
603 | test_line_count = 5 actual && | |
604 | test_i18ngrep "^Range-diff:$" 0000-* && | |
605 | grep "= 1: .* s/5/A" 0000-* && | |
606 | grep "= 2: .* s/4/A" 0000-* && | |
607 | grep "= 3: .* s/11/B" 0000-* && | |
608 | grep "= 4: .* s/12/B" 0000-* && | |
609 | ! grep "Notes" 0000-* && | |
610 | ! grep "note" 0000-* | |
611 | ' | |
612 | ||
613 | test_expect_success 'format-patch --range-diff with --notes' ' | |
614 | git notes add -m "topic note" topic && | |
615 | git notes add -m "unmodified note" unmodified && | |
616 | test_when_finished git notes remove topic unmodified && | |
617 | git format-patch --notes --cover-letter --range-diff=$prev \ | |
618 | master..unmodified >actual && | |
619 | test_when_finished "rm 000?-*" && | |
620 | test_line_count = 5 actual && | |
621 | test_i18ngrep "^Range-diff:$" 0000-* && | |
622 | grep "= 1: .* s/5/A" 0000-* && | |
623 | grep "= 2: .* s/4/A" 0000-* && | |
624 | grep "= 3: .* s/11/B" 0000-* && | |
3bdbdfb7 DL |
625 | grep "! 4: .* s/12/B" 0000-* && |
626 | sed s/Z/\ /g >expect <<-EOF && | |
9f726e1b | 627 | @@ Commit message |
3bdbdfb7 | 628 | Z |
9f726e1b DL |
629 | Z |
630 | Z ## Notes ## | |
3bdbdfb7 DL |
631 | - topic note |
632 | + unmodified note | |
633 | Z | |
634 | Z ## file ## | |
635 | Z@@ file: A | |
636 | EOF | |
9f726e1b | 637 | sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual && |
3bdbdfb7 DL |
638 | test_cmp expect actual |
639 | ' | |
640 | ||
828765df | 641 | test_expect_success 'format-patch --range-diff with format.notes config' ' |
5b583e6a DL |
642 | git notes add -m "topic note" topic && |
643 | git notes add -m "unmodified note" unmodified && | |
644 | test_when_finished git notes remove topic unmodified && | |
645 | test_config format.notes true && | |
646 | git format-patch --cover-letter --range-diff=$prev \ | |
647 | master..unmodified >actual && | |
648 | test_when_finished "rm 000?-*" && | |
649 | test_line_count = 5 actual && | |
650 | test_i18ngrep "^Range-diff:$" 0000-* && | |
651 | grep "= 1: .* s/5/A" 0000-* && | |
652 | grep "= 2: .* s/4/A" 0000-* && | |
653 | grep "= 3: .* s/11/B" 0000-* && | |
654 | grep "! 4: .* s/12/B" 0000-* && | |
655 | sed s/Z/\ /g >expect <<-EOF && | |
656 | @@ Commit message | |
657 | Z | |
658 | Z | |
659 | Z ## Notes ## | |
660 | - topic note | |
661 | + unmodified note | |
662 | Z | |
663 | Z ## file ## | |
664 | Z@@ file: A | |
665 | EOF | |
666 | sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual && | |
667 | test_cmp expect actual | |
668 | ' | |
669 | ||
670 | test_expect_success 'format-patch --range-diff with multiple notes' ' | |
671 | git notes --ref=note1 add -m "topic note1" topic && | |
672 | git notes --ref=note1 add -m "unmodified note1" unmodified && | |
673 | test_when_finished git notes --ref=note1 remove topic unmodified && | |
674 | git notes --ref=note2 add -m "topic note2" topic && | |
675 | git notes --ref=note2 add -m "unmodified note2" unmodified && | |
676 | test_when_finished git notes --ref=note2 remove topic unmodified && | |
677 | git format-patch --notes=note1 --notes=note2 --cover-letter --range-diff=$prev \ | |
678 | master..unmodified >actual && | |
679 | test_when_finished "rm 000?-*" && | |
680 | test_line_count = 5 actual && | |
681 | test_i18ngrep "^Range-diff:$" 0000-* && | |
682 | grep "= 1: .* s/5/A" 0000-* && | |
683 | grep "= 2: .* s/4/A" 0000-* && | |
684 | grep "= 3: .* s/11/B" 0000-* && | |
685 | grep "! 4: .* s/12/B" 0000-* && | |
686 | sed s/Z/\ /g >expect <<-EOF && | |
687 | @@ Commit message | |
688 | Z | |
689 | Z | |
690 | Z ## Notes (note1) ## | |
691 | - topic note1 | |
692 | + unmodified note1 | |
693 | Z | |
694 | Z | |
695 | Z ## Notes (note2) ## | |
696 | - topic note2 | |
697 | + unmodified note2 | |
698 | Z | |
699 | Z ## file ## | |
700 | Z@@ file: A | |
701 | EOF | |
702 | sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual && | |
703 | test_cmp expect actual | |
704 | ' | |
705 | ||
8884cf15 | 706 | test_done |