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