441
test $(git hash-object c) = $(git rev-parse A:a)
442
'
443
444
+# Testcase setup for rename/rename(1to2)/add-source conflict:
445
+# Commit A: new file: a
446
+# Commit B: rename a->b
447
+# Commit C: rename a->c, add completely different a
448
+#
449
+# Merging of B & C should NOT be clean; there's a rename/rename conflict
450
+
451
+test_expect_success 'setup rename/rename(1to2)/add-source conflict' '
452
+ git rm -rf . &&
453
+ git clean -fdqx &&
454
+ rm -rf .git &&
455
+ git init &&
456
+
457
+ printf "1\n2\n3\n4\n5\n6\n7\n" >a &&
458
+ git add a &&
459
+ git commit -m A &&
460
+ git tag A &&
461
+
462
+ git checkout -b B A &&
463
+ git mv a b &&
464
+ git commit -m B &&
465
+
466
+ git checkout -b C A &&
467
+ git mv a c &&
468
+ echo something completely different >a &&
469
+ git add a &&
470
+ git commit -m C
471
+'
472
+
473
+test_expect_failure 'detect conflict with rename/rename(1to2)/add-source merge' '
474
+ git checkout B^0 &&
475
+
476
+ test_must_fail git merge -s recursive C^0 &&
477
+
478
+ test 4 -eq $(git ls-files -s | wc -l) &&
479
+ test 0 -eq $(git ls-files -o | wc -l) &&
480
+
481
+ test $(git rev-parse 3:a) = $(git rev-parse C:a) &&
482
+ test $(git rev-parse 1:a) = $(git rev-parse A:a) &&
483
+ test $(git rev-parse 2:b) = $(git rev-parse B:b) &&
484
+ test $(git rev-parse 3:c) = $(git rev-parse C:c) &&
485
+
486
+ test -f a &&
487
+ test -f b &&
488
+ test -f c
489
+'
490
+
491
+test_expect_success 'setup rename/rename(1to2)/add-source resolvable conflict' '
492
+ git rm -rf . &&
493
+ git clean -fdqx &&
494
+ rm -rf .git &&
495
+ git init &&
496
+
497
+ >a &&
498
+ git add a &&
499
+ test_tick &&
500
+ git commit -m base &&
501
+ git tag A &&
502
+
503
+ git checkout -b B A &&
504
+ git mv a b &&
505
+ test_tick &&
506
+ git commit -m one &&
507
+
508
+ git checkout -b C A &&
509
+ git mv a b &&
510
+ echo important-info >a &&
511
+ git add a &&
512
+ test_tick &&
513
+ git commit -m two
514
+'
515
+
516
+test_expect_failure 'rename/rename/add-source still tracks new a file' '
517
+ git checkout C^0 &&
518
+ git merge -s recursive B^0 &&
519
+
520
+ test 2 -eq $(git ls-files -s | wc -l) &&
521
+ test 0 -eq $(git ls-files -o | wc -l) &&
522
+
523
+ test $(git rev-parse HEAD:a) = $(git rev-parse C:a) &&
524
+ test $(git rev-parse HEAD:b) = $(git rev-parse A:a)
525
+'
526
+
527
+test_expect_success 'setup rename/rename(1to2)/add-dest conflict' '
528
+ git rm -rf . &&
529
+ git clean -fdqx &&
530
+ rm -rf .git &&
531
+ git init &&
532
+
533
+ echo stuff >a &&
534
+ git add a &&
535
+ test_tick &&
536
+ git commit -m base &&
537
+ git tag A &&
538
+
539
+ git checkout -b B A &&
540
+ git mv a b &&
541
+ echo precious-data >c &&
542
+ git add c &&
543
+ test_tick &&
544
+ git commit -m one &&
545
+
546
+ git checkout -b C A &&
547
+ git mv a c &&
548
+ echo important-info >b &&
549
+ git add b &&
550
+ test_tick &&
551
+ git commit -m two
552
+'
553
+
554
+test_expect_failure 'rename/rename/add-dest merge still knows about conflicting file versions' '
555
+ git checkout C^0 &&
556
+ test_must_fail git merge -s recursive B^0 &&
557
+
558
+ test 5 -eq $(git ls-files -s | wc -l) &&
559
+ test 2 -eq $(git ls-files -u b | wc -l) &&
560
+ test 2 -eq $(git ls-files -u c | wc -l) &&
561
+
562
+ test $(git rev-parse :1:a) = $(git rev-parse A:a) &&
563
+ test $(git rev-parse :2:b) = $(git rev-parse C:b) &&
564
+ test $(git rev-parse :3:b) = $(git rev-parse B:b) &&
565
+ test $(git rev-parse :2:c) = $(git rev-parse C:c) &&
566
+ test $(git rev-parse :3:c) = $(git rev-parse B:c)
567
+'
568
+
569
test_done