directory rename detection: directory splitting testcases
Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Apr 19, 2018 at 10:57 UTC
509555d8ad41b348ac705c458473912e090df289
1 file changed
+143
t/t6043-merge-rename-directories.sh
+143
@@ -439,4 +439,147 @@ test_expect_failure '1f-check: Split a directory into two other directories' '
439
# in section 2, plus testcases 3a and 4a.
440
###########################################################################
441
442
+
443
+###########################################################################
444
+# SECTION 2: Split into multiple directories, with equal number of paths
445
+#
446
+# Explore the splitting-a-directory rules a bit; what happens in the
447
+# edge cases?
448
+#
449
+# Note that there is a closely related case of a directory not being
450
+# split on either side of history, but being renamed differently on
451
+# each side. See testcase 8e for that.
452
+###########################################################################
453
+
454
+# Testcase 2a, Directory split into two on one side, with equal numbers of paths
455
+# Commit O: z/{b,c}
456
+# Commit A: y/b, w/c
457
+# Commit B: z/{b,c,d}
458
+# Expected: y/b, w/c, z/d, with warning about z/ -> (y/ vs. w/) conflict
459
+test_expect_success '2a-setup: Directory split into two on one side, with equal numbers of paths' '
460
+ test_create_repo 2a &&
461
+ (
462
+ cd 2a &&
463
+
464
+ mkdir z &&
465
+ echo b >z/b &&
466
+ echo c >z/c &&
467
+ git add z &&
468
+ test_tick &&
469
+ git commit -m "O" &&
470
+
471
+ git branch O &&
472
+ git branch A &&
473
+ git branch B &&
474
+
475
+ git checkout A &&
476
+ mkdir y &&
477
+ mkdir w &&
478
+ git mv z/b y/ &&
479
+ git mv z/c w/ &&
480
+ test_tick &&
481
+ git commit -m "A" &&
482
+
483
+ git checkout B &&
484
+ echo d >z/d &&
485
+ git add z/d &&
486
+ test_tick &&
487
+ git commit -m "B"
488
+ )
489
+'
490
+
491
+test_expect_failure '2a-check: Directory split into two on one side, with equal numbers of paths' '
492
+ (
493
+ cd 2a &&
494
+
495
+ git checkout A^0 &&
496
+
497
+ test_must_fail git merge -s recursive B^0 >out &&
498
+ test_i18ngrep "CONFLICT.*directory rename split" out &&
499
+
500
+ git ls-files -s >out &&
501
+ test_line_count = 3 out &&
502
+ git ls-files -u >out &&
503
+ test_line_count = 0 out &&
504
+ git ls-files -o >out &&
505
+ test_line_count = 1 out &&
506
+
507
+ git rev-parse >actual \
508
+ :0:y/b :0:w/c :0:z/d &&
509
+ git rev-parse >expect \
510
+ O:z/b O:z/c B:z/d &&
511
+ test_cmp expect actual
512
+ )
513
+'
514
+
515
+# Testcase 2b, Directory split into two on one side, with equal numbers of paths
516
+# Commit O: z/{b,c}
517
+# Commit A: y/b, w/c
518
+# Commit B: z/{b,c}, x/d
519
+# Expected: y/b, w/c, x/d; No warning about z/ -> (y/ vs. w/) conflict
520
+test_expect_success '2b-setup: Directory split into two on one side, with equal numbers of paths' '
521
+ test_create_repo 2b &&
522
+ (
523
+ cd 2b &&
524
+
525
+ mkdir z &&
526
+ echo b >z/b &&
527
+ echo c >z/c &&
528
+ git add z &&
529
+ test_tick &&
530
+ git commit -m "O" &&
531
+
532
+ git branch O &&
533
+ git branch A &&
534
+ git branch B &&
535
+
536
+ git checkout A &&
537
+ mkdir y &&
538
+ mkdir w &&
539
+ git mv z/b y/ &&
540
+ git mv z/c w/ &&
541
+ test_tick &&
542
+ git commit -m "A" &&
543
+
544
+ git checkout B &&
545
+ mkdir x &&
546
+ echo d >x/d &&
547
+ git add x/d &&
548
+ test_tick &&
549
+ git commit -m "B"
550
+ )
551
+'
552
+
553
+test_expect_success '2b-check: Directory split into two on one side, with equal numbers of paths' '
554
+ (
555
+ cd 2b &&
556
+
557
+ git checkout A^0 &&
558
+
559
+ git merge -s recursive B^0 >out &&
560
+
561
+ git ls-files -s >out &&
562
+ test_line_count = 3 out &&
563
+ git ls-files -u >out &&
564
+ test_line_count = 0 out &&
565
+ git ls-files -o >out &&
566
+ test_line_count = 1 out &&
567
+
568
+ git rev-parse >actual \
569
+ :0:y/b :0:w/c :0:x/d &&
570
+ git rev-parse >expect \
571
+ O:z/b O:z/c B:x/d &&
572
+ test_cmp expect actual &&
573
+ test_i18ngrep ! "CONFLICT.*directory rename split" out
574
+ )
575
+'
576
+
577
+###########################################################################
578
+# Rules suggested by section 2:
579
+#
580
+# None; the rule was already covered in section 1. These testcases are
581
+# here just to make sure the conflict resolution and necessary warning
582
+# messages are handled correctly.
583
+###########################################################################
584
+
585
test_done