]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6426-merge-skip-unneeded-updates.sh
Merge branch 'es/add-doc-list-short-form-of-all-in-synopsis'
[thirdparty/git.git] / t / t6426-merge-skip-unneeded-updates.sh
CommitLineData
c04ba517
EN
1#!/bin/sh
2
3test_description="merge cases"
4
5# The setup for all of them, pictorially, is:
6#
7# A
8# o
9# / \
10# O o ?
11# \ /
12# o
13# B
14#
15# To help make it easier to follow the flow of tests, they have been
16# divided into sections and each test will start with a quick explanation
17# of what commits O, A, and B contain.
18#
19# Notation:
20# z/{b,c} means files z/b and z/c both exist
21# x/d_1 means file x/d exists with content d1. (Purpose of the
22# underscore notation is to differentiate different
23# files that might be renamed into each other's paths.)
24
25. ./test-lib.sh
f06481f1 26. "$TEST_DIRECTORY"/lib-merge.sh
c04ba517
EN
27
28
29###########################################################################
30# SECTION 1: Cases involving no renames (one side has subset of changes of
31# the other side)
32###########################################################################
33
34# Testcase 1a, Changes on A, subset of changes on B
35# Commit O: b_1
36# Commit A: b_2
37# Commit B: b_3
38# Expected: b_2
39
da1e295e 40test_setup_1a () {
6693fb3f 41 git init 1a_$1 &&
c04ba517 42 (
da1e295e 43 cd 1a_$1 &&
c04ba517
EN
44
45 test_write_lines 1 2 3 4 5 6 7 8 9 10 >b &&
46 git add b &&
47 test_tick &&
48 git commit -m "O" &&
49
50 git branch O &&
51 git branch A &&
52 git branch B &&
53
54 git checkout A &&
55 test_write_lines 1 2 3 4 5 5.5 6 7 8 9 10 10.5 >b &&
56 git add b &&
57 test_tick &&
58 git commit -m "A" &&
59
60 git checkout B &&
61 test_write_lines 1 2 3 4 5 5.5 6 7 8 9 10 >b &&
62 git add b &&
63 test_tick &&
64 git commit -m "B"
65 )
da1e295e 66}
c04ba517 67
da1e295e
EN
68test_expect_success '1a-L: Modify(A)/Modify(B), change on B subset of A' '
69 test_setup_1a L &&
c04ba517 70 (
da1e295e 71 cd 1a_L &&
c04ba517
EN
72
73 git checkout A^0 &&
74
70e24186 75 test-tool chmtime --get -3600 b >old-mtime &&
c04ba517
EN
76
77 GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
78
c04ba517
EN
79 test_must_be_empty err &&
80
9f697ded
EN
81 # Make sure b was NOT updated
82 test-tool chmtime --get b >new-mtime &&
83 test_cmp old-mtime new-mtime &&
c04ba517
EN
84
85 git ls-files -s >index_files &&
86 test_line_count = 1 index_files &&
87
88 git rev-parse >actual HEAD:b &&
89 git rev-parse >expect A:b &&
90 test_cmp expect actual &&
91
92 git hash-object b >actual &&
93 git rev-parse A:b >expect &&
94 test_cmp expect actual
95 )
96'
97
da1e295e
EN
98test_expect_success '1a-R: Modify(A)/Modify(B), change on B subset of A' '
99 test_setup_1a R &&
c04ba517 100 (
da1e295e 101 cd 1a_R &&
c04ba517
EN
102
103 git checkout B^0 &&
104
70e24186 105 test-tool chmtime --get -3600 b >old-mtime &&
c04ba517
EN
106 GIT_MERGE_VERBOSITY=3 git merge -s recursive A^0 >out 2>err &&
107
9f697ded
EN
108 # Make sure b WAS updated
109 test-tool chmtime --get b >new-mtime &&
110 test $(cat old-mtime) -lt $(cat new-mtime) &&
111
c04ba517
EN
112 test_must_be_empty err &&
113
114 git ls-files -s >index_files &&
115 test_line_count = 1 index_files &&
116
117 git rev-parse >actual HEAD:b &&
118 git rev-parse >expect A:b &&
119 test_cmp expect actual &&
120
121 git hash-object b >actual &&
122 git rev-parse A:b >expect &&
123 test_cmp expect actual
124 )
125'
126
127
128###########################################################################
129# SECTION 2: Cases involving basic renames
130###########################################################################
131
132# Testcase 2a, Changes on A, rename on B
133# Commit O: b_1
134# Commit A: b_2
135# Commit B: c_1
136# Expected: c_2
137
da1e295e 138test_setup_2a () {
6693fb3f 139 git init 2a_$1 &&
c04ba517 140 (
da1e295e 141 cd 2a_$1 &&
c04ba517
EN
142
143 test_seq 1 10 >b &&
144 git add b &&
145 test_tick &&
146 git commit -m "O" &&
147
148 git branch O &&
149 git branch A &&
150 git branch B &&
151
152 git checkout A &&
153 test_seq 1 11 >b &&
154 git add b &&
155 test_tick &&
156 git commit -m "A" &&
157
158 git checkout B &&
159 git mv b c &&
160 test_tick &&
161 git commit -m "B"
162 )
da1e295e 163}
c04ba517 164
da1e295e
EN
165test_expect_success '2a-L: Modify/rename, merge into modify side' '
166 test_setup_2a L &&
c04ba517 167 (
da1e295e 168 cd 2a_L &&
c04ba517
EN
169
170 git checkout A^0 &&
171
9f697ded 172 test_path_is_missing c &&
c04ba517
EN
173 GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
174
9f697ded 175 test_path_is_file c &&
c04ba517
EN
176
177 git ls-files -s >index_files &&
178 test_line_count = 1 index_files &&
179
180 git rev-parse >actual HEAD:c &&
181 git rev-parse >expect A:b &&
182 test_cmp expect actual &&
183
184 git hash-object c >actual &&
185 git rev-parse A:b >expect &&
186 test_cmp expect actual &&
187
188 test_must_fail git rev-parse HEAD:b &&
189 test_path_is_missing b
190 )
191'
192
da1e295e
EN
193test_expect_success '2a-R: Modify/rename, merge into rename side' '
194 test_setup_2a R &&
c04ba517 195 (
da1e295e 196 cd 2a_R &&
c04ba517
EN
197
198 git checkout B^0 &&
199
70e24186 200 test-tool chmtime --get -3600 c >old-mtime &&
c04ba517
EN
201 GIT_MERGE_VERBOSITY=3 git merge -s recursive A^0 >out 2>err &&
202
9f697ded
EN
203 # Make sure c WAS updated
204 test-tool chmtime --get c >new-mtime &&
205 test $(cat old-mtime) -lt $(cat new-mtime) &&
206
c04ba517
EN
207 test_must_be_empty err &&
208
209 git ls-files -s >index_files &&
210 test_line_count = 1 index_files &&
211
212 git rev-parse >actual HEAD:c &&
213 git rev-parse >expect A:b &&
214 test_cmp expect actual &&
215
216 git hash-object c >actual &&
217 git rev-parse A:b >expect &&
218 test_cmp expect actual &&
219
220 test_must_fail git rev-parse HEAD:b &&
221 test_path_is_missing b
222 )
223'
224
225# Testcase 2b, Changed and renamed on A, subset of changes on B
226# Commit O: b_1
227# Commit A: c_2
228# Commit B: b_3
229# Expected: c_2
230
da1e295e 231test_setup_2b () {
6693fb3f 232 git init 2b_$1 &&
c04ba517 233 (
da1e295e 234 cd 2b_$1 &&
c04ba517
EN
235
236 test_write_lines 1 2 3 4 5 6 7 8 9 10 >b &&
237 git add b &&
238 test_tick &&
239 git commit -m "O" &&
240
241 git branch O &&
242 git branch A &&
243 git branch B &&
244
245 git checkout A &&
246 test_write_lines 1 2 3 4 5 5.5 6 7 8 9 10 10.5 >b &&
247 git add b &&
248 git mv b c &&
249 test_tick &&
250 git commit -m "A" &&
251
252 git checkout B &&
253 test_write_lines 1 2 3 4 5 5.5 6 7 8 9 10 >b &&
254 git add b &&
255 test_tick &&
256 git commit -m "B"
257 )
da1e295e 258}
c04ba517 259
da1e295e
EN
260test_expect_success '2b-L: Rename+Mod(A)/Mod(B), B mods subset of A' '
261 test_setup_2b L &&
c04ba517 262 (
da1e295e 263 cd 2b_L &&
c04ba517
EN
264
265 git checkout A^0 &&
266
70e24186 267 test-tool chmtime --get -3600 c >old-mtime &&
c04ba517
EN
268 GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
269
c04ba517
EN
270 test_must_be_empty err &&
271
9f697ded
EN
272 # Make sure c WAS updated
273 test-tool chmtime --get c >new-mtime &&
274 test_cmp old-mtime new-mtime &&
c04ba517
EN
275
276 git ls-files -s >index_files &&
277 test_line_count = 1 index_files &&
278
279 git rev-parse >actual HEAD:c &&
280 git rev-parse >expect A:c &&
281 test_cmp expect actual &&
282
283 git hash-object c >actual &&
284 git rev-parse A:c >expect &&
285 test_cmp expect actual &&
286
287 test_must_fail git rev-parse HEAD:b &&
288 test_path_is_missing b
289 )
290'
291
da1e295e
EN
292test_expect_success '2b-R: Rename+Mod(A)/Mod(B), B mods subset of A' '
293 test_setup_2b R &&
c04ba517 294 (
da1e295e 295 cd 2b_R &&
c04ba517
EN
296
297 git checkout B^0 &&
298
9f697ded 299 test_path_is_missing c &&
c04ba517
EN
300 GIT_MERGE_VERBOSITY=3 git merge -s recursive A^0 >out 2>err &&
301
9f697ded
EN
302 # Make sure c now present (and thus was updated)
303 test_path_is_file c &&
304
c04ba517
EN
305 test_must_be_empty err &&
306
307 git ls-files -s >index_files &&
308 test_line_count = 1 index_files &&
309
310 git rev-parse >actual HEAD:c &&
311 git rev-parse >expect A:c &&
312 test_cmp expect actual &&
313
314 git hash-object c >actual &&
315 git rev-parse A:c >expect &&
316 test_cmp expect actual &&
317
318 test_must_fail git rev-parse HEAD:b &&
319 test_path_is_missing b
320 )
321'
322
323# Testcase 2c, Changes on A, rename on B
324# Commit O: b_1
325# Commit A: b_2, c_3
326# Commit B: c_1
327# Expected: rename/add conflict c_2 vs c_3
328#
329# NOTE: Since A modified b_1->b_2, and B renamed b_1->c_1, the threeway
330# merge of those files should result in c_2. We then should have a
331# rename/add conflict between c_2 and c_3. However, if we note in
332# merge_content() that A had the right contents (b_2 has same
333# contents as c_2, just at a different name), and that A had the
334# right path present (c_3 existed) and thus decides that it can
335# skip the update, then we're in trouble. This test verifies we do
336# not make that particular mistake.
337
da1e295e 338test_setup_2c () {
6693fb3f 339 git init 2c &&
c04ba517
EN
340 (
341 cd 2c &&
342
343 test_seq 1 10 >b &&
344 git add b &&
345 test_tick &&
346 git commit -m "O" &&
347
348 git branch O &&
349 git branch A &&
350 git branch B &&
351
352 git checkout A &&
353 test_seq 1 11 >b &&
354 echo whatever >c &&
355 git add b c &&
356 test_tick &&
357 git commit -m "A" &&
358
359 git checkout B &&
360 git mv b c &&
361 test_tick &&
362 git commit -m "B"
363 )
da1e295e 364}
c04ba517 365
da1e295e
EN
366test_expect_success '2c: Modify b & add c VS rename b->c' '
367 test_setup_2c &&
c04ba517
EN
368 (
369 cd 2c &&
370
371 git checkout A^0 &&
372
70e24186 373 test-tool chmtime --get -3600 c >old-mtime &&
079b087c
ES
374 GIT_MERGE_VERBOSITY=3 &&
375 export GIT_MERGE_VERBOSITY &&
376 test_must_fail git merge -s recursive B^0 >out 2>err &&
c04ba517 377
6789275d 378 test_grep "CONFLICT (.*/add):" out &&
9f697ded
EN
379 test_must_be_empty err &&
380
dcb47e52
EN
381 git ls-files -s >index_files &&
382 test_line_count = 2 index_files &&
383
384 # Ensure b was removed
385 test_path_is_missing b &&
386
387 # Make sure c WAS updated...
9f697ded 388 test-tool chmtime --get c >new-mtime &&
dcb47e52
EN
389 test $(cat old-mtime) -lt $(cat new-mtime) &&
390
391 # ...and has correct index entries and working tree contents
392 git rev-parse >actual :2:c :3:c &&
393 git rev-parse >expect A:c A:b &&
394 test_cmp expect actual &&
395
396 git cat-file -p A:b >>merge-me &&
397 git cat-file -p A:c >>merged &&
398 >empty &&
399 test_must_fail git merge-file \
400 -L "HEAD" \
401 -L "" \
402 -L "B^0" \
403 merged empty merge-me &&
404 test_cmp merged c
c04ba517
EN
405 )
406'
407
408
409###########################################################################
410# SECTION 3: Cases involving directory renames
411#
412# NOTE:
413# Directory renames only apply when one side renames a directory, and the
414# other side adds or renames a path into that directory. Applying the
415# directory rename to that new path creates a new pathname that didn't
416# exist on either side of history. Thus, it is impossible for the
417# merge contents to already be at the right path, so all of these checks
418# exist just to make sure that updates are not skipped.
419###########################################################################
420
421# Testcase 3a, Change + rename into dir foo on A, dir rename foo->bar on B
422# Commit O: bq_1, foo/whatever
423# Commit A: foo/{bq_2, whatever}
424# Commit B: bq_1, bar/whatever
425# Expected: bar/{bq_2, whatever}
426
da1e295e 427test_setup_3a () {
6693fb3f 428 git init 3a_$1 &&
c04ba517 429 (
da1e295e 430 cd 3a_$1 &&
c04ba517
EN
431
432 mkdir foo &&
433 test_seq 1 10 >bq &&
434 test_write_lines a b c d e f g h i j k >foo/whatever &&
435 git add bq foo/whatever &&
436 test_tick &&
437 git commit -m "O" &&
438
439 git branch O &&
440 git branch A &&
441 git branch B &&
442
443 git checkout A &&
444 test_seq 1 11 >bq &&
445 git add bq &&
446 git mv bq foo/ &&
447 test_tick &&
448 git commit -m "A" &&
449
450 git checkout B &&
451 git mv foo/ bar/ &&
452 test_tick &&
453 git commit -m "B"
454 )
da1e295e 455}
c04ba517 456
da1e295e
EN
457test_expect_success '3a-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
458 test_setup_3a L &&
c04ba517 459 (
da1e295e 460 cd 3a_L &&
c04ba517
EN
461
462 git checkout A^0 &&
463
9f697ded 464 test_path_is_missing bar/bq &&
8c8e5bd6 465 GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
c04ba517 466
c04ba517
EN
467 test_must_be_empty err &&
468
9f697ded
EN
469 test_path_is_file bar/bq &&
470
c04ba517
EN
471 git ls-files -s >index_files &&
472 test_line_count = 2 index_files &&
473
474 git rev-parse >actual HEAD:bar/bq HEAD:bar/whatever &&
475 git rev-parse >expect A:foo/bq A:foo/whatever &&
476 test_cmp expect actual &&
477
478 git hash-object bar/bq bar/whatever >actual &&
479 git rev-parse A:foo/bq A:foo/whatever >expect &&
480 test_cmp expect actual &&
481
482 test_must_fail git rev-parse HEAD:bq HEAD:foo/bq &&
45a26864
ÆAB
483 test_path_is_missing bq &&
484 test_path_is_missing foo/bq &&
485 test_path_is_missing foo/whatever
c04ba517
EN
486 )
487'
488
da1e295e
EN
489test_expect_success '3a-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
490 test_setup_3a R &&
c04ba517 491 (
da1e295e 492 cd 3a_R &&
c04ba517
EN
493
494 git checkout B^0 &&
495
9f697ded 496 test_path_is_missing bar/bq &&
8c8e5bd6 497 GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive A^0 >out 2>err &&
c04ba517 498
c04ba517
EN
499 test_must_be_empty err &&
500
9f697ded
EN
501 test_path_is_file bar/bq &&
502
c04ba517
EN
503 git ls-files -s >index_files &&
504 test_line_count = 2 index_files &&
505
506 git rev-parse >actual HEAD:bar/bq HEAD:bar/whatever &&
507 git rev-parse >expect A:foo/bq A:foo/whatever &&
508 test_cmp expect actual &&
509
510 git hash-object bar/bq bar/whatever >actual &&
511 git rev-parse A:foo/bq A:foo/whatever >expect &&
512 test_cmp expect actual &&
513
514 test_must_fail git rev-parse HEAD:bq HEAD:foo/bq &&
45a26864
ÆAB
515 test_path_is_missing bq &&
516 test_path_is_missing foo/bq &&
517 test_path_is_missing foo/whatever
c04ba517
EN
518 )
519'
520
521# Testcase 3b, rename into dir foo on A, dir rename foo->bar + change on B
522# Commit O: bq_1, foo/whatever
523# Commit A: foo/{bq_1, whatever}
524# Commit B: bq_2, bar/whatever
525# Expected: bar/{bq_2, whatever}
526
da1e295e 527test_setup_3b () {
6693fb3f 528 git init 3b_$1 &&
c04ba517 529 (
da1e295e 530 cd 3b_$1 &&
c04ba517
EN
531
532 mkdir foo &&
533 test_seq 1 10 >bq &&
534 test_write_lines a b c d e f g h i j k >foo/whatever &&
535 git add bq foo/whatever &&
536 test_tick &&
537 git commit -m "O" &&
538
539 git branch O &&
540 git branch A &&
541 git branch B &&
542
543 git checkout A &&
544 git mv bq foo/ &&
545 test_tick &&
546 git commit -m "A" &&
547
548 git checkout B &&
549 test_seq 1 11 >bq &&
550 git add bq &&
551 git mv foo/ bar/ &&
552 test_tick &&
553 git commit -m "B"
554 )
da1e295e 555}
c04ba517 556
da1e295e
EN
557test_expect_success '3b-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
558 test_setup_3b L &&
c04ba517 559 (
da1e295e 560 cd 3b_L &&
c04ba517
EN
561
562 git checkout A^0 &&
563
9f697ded 564 test_path_is_missing bar/bq &&
8c8e5bd6 565 GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
c04ba517 566
c04ba517
EN
567 test_must_be_empty err &&
568
9f697ded
EN
569 test_path_is_file bar/bq &&
570
c04ba517
EN
571 git ls-files -s >index_files &&
572 test_line_count = 2 index_files &&
573
574 git rev-parse >actual HEAD:bar/bq HEAD:bar/whatever &&
575 git rev-parse >expect B:bq A:foo/whatever &&
576 test_cmp expect actual &&
577
578 git hash-object bar/bq bar/whatever >actual &&
579 git rev-parse B:bq A:foo/whatever >expect &&
580 test_cmp expect actual &&
581
582 test_must_fail git rev-parse HEAD:bq HEAD:foo/bq &&
45a26864
ÆAB
583 test_path_is_missing bq &&
584 test_path_is_missing foo/bq &&
585 test_path_is_missing foo/whatever
c04ba517
EN
586 )
587'
588
da1e295e
EN
589test_expect_success '3b-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
590 test_setup_3b R &&
c04ba517 591 (
da1e295e 592 cd 3b_R &&
c04ba517
EN
593
594 git checkout B^0 &&
595
9f697ded 596 test_path_is_missing bar/bq &&
8c8e5bd6 597 GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive A^0 >out 2>err &&
c04ba517 598
c04ba517
EN
599 test_must_be_empty err &&
600
9f697ded
EN
601 test_path_is_file bar/bq &&
602
c04ba517
EN
603 git ls-files -s >index_files &&
604 test_line_count = 2 index_files &&
605
606 git rev-parse >actual HEAD:bar/bq HEAD:bar/whatever &&
607 git rev-parse >expect B:bq A:foo/whatever &&
608 test_cmp expect actual &&
609
610 git hash-object bar/bq bar/whatever >actual &&
611 git rev-parse B:bq A:foo/whatever >expect &&
612 test_cmp expect actual &&
613
614 test_must_fail git rev-parse HEAD:bq HEAD:foo/bq &&
45a26864
ÆAB
615 test_path_is_missing bq &&
616 test_path_is_missing foo/bq &&
617 test_path_is_missing foo/whatever
c04ba517
EN
618 )
619'
620
621###########################################################################
622# SECTION 4: Cases involving dirty changes
623###########################################################################
624
625# Testcase 4a, Changed on A, subset of changes on B, locally modified
626# Commit O: b_1
627# Commit A: b_2
628# Commit B: b_3
629# Working copy: b_4
630# Expected: b_2 for merge, b_4 in working copy
631
da1e295e 632test_setup_4a () {
6693fb3f 633 git init 4a &&
c04ba517
EN
634 (
635 cd 4a &&
636
637 test_write_lines 1 2 3 4 5 6 7 8 9 10 >b &&
638 git add b &&
639 test_tick &&
640 git commit -m "O" &&
641
642 git branch O &&
643 git branch A &&
644 git branch B &&
645
646 git checkout A &&
647 test_write_lines 1 2 3 4 5 5.5 6 7 8 9 10 10.5 >b &&
648 git add b &&
649 test_tick &&
650 git commit -m "A" &&
651
652 git checkout B &&
653 test_write_lines 1 2 3 4 5 5.5 6 7 8 9 10 >b &&
654 git add b &&
655 test_tick &&
656 git commit -m "B"
657 )
da1e295e 658}
c04ba517
EN
659
660# NOTE: For as long as we continue using unpack_trees() without index_only
6d12b533 661# set to true, it will error out on a case like this claiming that the locally
c04ba517
EN
662# modified file would be overwritten by the merge. Getting this testcase
663# correct requires doing the merge in-memory first, then realizing that no
664# updates to the file are necessary, and thus that we can just leave the path
665# alone.
f06481f1 666test_expect_merge_algorithm failure success '4a: Change on A, change on B subset of A, dirty mods present' '
da1e295e 667 test_setup_4a &&
c04ba517
EN
668 (
669 cd 4a &&
670
671 git checkout A^0 &&
672 echo "File rewritten" >b &&
673
70e24186 674 test-tool chmtime --get -3600 b >old-mtime &&
c04ba517
EN
675
676 GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
677
c04ba517
EN
678 test_must_be_empty err &&
679
9f697ded
EN
680 # Make sure b was NOT updated
681 test-tool chmtime --get b >new-mtime &&
682 test_cmp old-mtime new-mtime &&
c04ba517
EN
683
684 git ls-files -s >index_files &&
685 test_line_count = 1 index_files &&
686
687 git rev-parse >actual :0:b &&
688 git rev-parse >expect A:b &&
689 test_cmp expect actual &&
690
691 git hash-object b >actual &&
692 echo "File rewritten" | git hash-object --stdin >expect &&
693 test_cmp expect actual
694 )
695'
696
697# Testcase 4b, Changed+renamed on A, subset of changes on B, locally modified
698# Commit O: b_1
699# Commit A: c_2
700# Commit B: b_3
701# Working copy: c_4
702# Expected: c_2
703
da1e295e 704test_setup_4b () {
6693fb3f 705 git init 4b &&
c04ba517
EN
706 (
707 cd 4b &&
708
709 test_write_lines 1 2 3 4 5 6 7 8 9 10 >b &&
710 git add b &&
711 test_tick &&
712 git commit -m "O" &&
713
714 git branch O &&
715 git branch A &&
716 git branch B &&
717
718 git checkout A &&
719 test_write_lines 1 2 3 4 5 5.5 6 7 8 9 10 10.5 >b &&
720 git add b &&
721 git mv b c &&
722 test_tick &&
723 git commit -m "A" &&
724
725 git checkout B &&
726 test_write_lines 1 2 3 4 5 5.5 6 7 8 9 10 >b &&
727 git add b &&
728 test_tick &&
729 git commit -m "B"
730 )
da1e295e 731}
c04ba517 732
da1e295e
EN
733test_expect_success '4b: Rename+Mod(A)/Mod(B), change on B subset of A, dirty mods present' '
734 test_setup_4b &&
c04ba517
EN
735 (
736 cd 4b &&
737
738 git checkout A^0 &&
739 echo "File rewritten" >c &&
740
70e24186 741 test-tool chmtime --get -3600 c >old-mtime &&
c04ba517
EN
742
743 GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
744
c04ba517
EN
745 test_must_be_empty err &&
746
9f697ded
EN
747 # Make sure c was NOT updated
748 test-tool chmtime --get c >new-mtime &&
749 test_cmp old-mtime new-mtime &&
c04ba517
EN
750
751 git ls-files -s >index_files &&
752 test_line_count = 1 index_files &&
753
754 git rev-parse >actual :0:c &&
755 git rev-parse >expect A:c &&
756 test_cmp expect actual &&
757
758 git hash-object c >actual &&
759 echo "File rewritten" | git hash-object --stdin >expect &&
760 test_cmp expect actual &&
761
762 test_must_fail git rev-parse HEAD:b &&
763 test_path_is_missing b
764 )
765'
766
767test_done