test-dir-iterator: do not assume errno values
[gitweb.git] / t / t4300-merge-tree.sh
index 2defb422e8813c1ca314939aedba1d33c40dd388..d87cc7d9efde9d728825ae84b4a329b720b6d821 100755 (executable)
@@ -25,25 +25,19 @@ EXPECTED
 '
 
 test_expect_success 'file add !A, B' '
-       cat >expected <<\EXPECTED &&
-EXPECTED
-
        git reset --hard initial &&
        test_commit "add-not-a-b" "ONE" "AAA" &&
        git merge-tree initial add-not-a-b initial >actual &&
-       test_cmp expected actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'file add A, B (same)' '
-       cat >expected <<\EXPECTED &&
-EXPECTED
-
        git reset --hard initial &&
        test_commit "add-a-b-same-A" "ONE" "AAA" &&
        git reset --hard initial &&
        test_commit "add-a-b-same-B" "ONE" "AAA" &&
        git merge-tree initial add-a-b-same-A add-a-b-same-B >actual &&
-       test_cmp expected actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'file add A, B (different)' '
@@ -68,13 +62,10 @@ EXPECTED
 '
 
 test_expect_success 'file change A, !B' '
-       cat >expected <<\EXPECTED &&
-EXPECTED
-
        git reset --hard initial &&
        test_commit "change-a-not-b" "initial-file" "BBB" &&
        git merge-tree initial change-a-not-b initial >actual &&
-       test_cmp expected actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'file change !A, B' '
@@ -94,15 +85,12 @@ EXPECTED
 '
 
 test_expect_success 'file change A, B (same)' '
-       cat >expected <<\EXPECTED &&
-EXPECTED
-
        git reset --hard initial &&
        test_commit "change-a-b-same-A" "initial-file" "AAA" &&
        git reset --hard initial &&
        test_commit "change-a-b-same-B" "initial-file" "AAA" &&
        git merge-tree initial change-a-b-same-A change-a-b-same-B >actual &&
-       test_cmp expected actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'file change A, B (different)' '
@@ -175,16 +163,13 @@ AAA" &&
 '
 
 test_expect_success 'file remove A, !B' '
-       cat >expected <<\EXPECTED &&
-EXPECTED
-
        git reset --hard initial &&
        test_commit "rm-a-not-b-base" "ONE" "AAA" &&
        git rm ONE &&
        git commit -m "rm-a-not-b" &&
        git tag "rm-a-not-b" &&
        git merge-tree rm-a-not-b-base rm-a-not-b rm-a-not-b-base >actual &&
-       test_cmp expected actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'file remove !A, B' '
@@ -206,16 +191,13 @@ EXPECTED
 '
 
 test_expect_success 'file remove A, B (same)' '
-       cat >expected <<\EXPECTED &&
-EXPECTED
-
        git reset --hard initial &&
        test_commit "rm-a-b-base" "ONE" "AAA" &&
        git rm ONE &&
        git commit -m "rm-a-b" &&
        git tag "rm-a-b" &&
        git merge-tree rm-a-b-base rm-a-b rm-a-b >actual &&
-       test_cmp expected actual
+       test_must_be_empty actual
 '
 
 test_expect_success 'file change A, remove B' '
@@ -259,6 +241,55 @@ EXPECTED
        test_cmp expected actual
 '
 
+test_expect_success 'tree add A, B (same)' '
+       git reset --hard initial &&
+       mkdir sub &&
+       test_commit "add sub/file" "sub/file" "file" add-tree-A &&
+       git merge-tree initial add-tree-A add-tree-A >actual &&
+       test_must_be_empty actual
+'
+
+test_expect_success 'tree add A, B (different)' '
+       cat >expect <<-\EOF &&
+       added in both
+         our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file
+         their  100644 ba629238ca89489f2b350e196ca445e09d8bb834 sub/file
+       @@ -1 +1,5 @@
+       +<<<<<<< .our
+        AAA
+       +=======
+       +BBB
+       +>>>>>>> .their
+       EOF
+       git reset --hard initial &&
+       mkdir sub &&
+       test_commit "add sub/file" "sub/file" "AAA" add-tree-a-b-A &&
+       git reset --hard initial &&
+       mkdir sub &&
+       test_commit "add sub/file" "sub/file" "BBB" add-tree-a-b-B &&
+       git merge-tree initial add-tree-a-b-A add-tree-a-b-B >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'tree unchanged A, removed B' '
+       cat >expect <<-\EOF &&
+       removed in remote
+         base   100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file
+         our    100644 43d5a8ed6ef6c00ff775008633f95787d088285d sub/file
+       @@ -1 +0,0 @@
+       -AAA
+       EOF
+       git reset --hard initial &&
+       mkdir sub &&
+       test_commit "add sub/file" "sub/file" "AAA" tree-remove-b-initial &&
+       git rm sub/file &&
+       test_tick &&
+       git commit -m "remove sub/file" &&
+       git tag tree-remove-b-B &&
+       git merge-tree tree-remove-b-initial tree-remove-b-initial tree-remove-b-B >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success 'turn file to tree' '
        git reset --hard initial &&
        rm initial-file &&