[PATCH] Retitle 'inspecting what happened' section.
[git.git] / t / t1000-read-tree-m-3way.sh
index c435887..c387e9e 100755 (executable)
@@ -75,12 +75,13 @@ In addition:
 . ../lib-read-tree-m-3way.sh
 
 ################################################################
-# This is the "no trivial merge unless all three exists" table.
+# Trivial "majority when 3 stages exist" merge plus #2ALT, #3ALT
+# and #5ALT trivial merges.
 
 cat >expected <<\EOF
 100644 X 2     AA
 100644 X 3     AA
-100644 X 2     AN
+100644 X 0     AN
 100644 X 1     DD
 100644 X 3     DF
 100644 X 2     DF/DF
@@ -88,15 +89,14 @@ cat >expected <<\EOF
 100644 X 3     DM
 100644 X 1     DN
 100644 X 3     DN
-100644 X 2     LL
-100644 X 3     LL
+100644 X 0     LL
 100644 X 1     MD
 100644 X 2     MD
 100644 X 1     MM
 100644 X 2     MM
 100644 X 3     MM
 100644 X 0     MN
-100644 X 3     NA
+100644 X 0     NA
 100644 X 1     ND
 100644 X 2     ND
 100644 X 0     NM
@@ -107,7 +107,7 @@ cat >expected <<\EOF
 100644 X 3     TT
 100644 X 2     Z/AA
 100644 X 3     Z/AA
-100644 X 2     Z/AN
+100644 X 0     Z/AN
 100644 X 1     Z/DD
 100644 X 1     Z/DM
 100644 X 3     Z/DM
@@ -119,7 +119,7 @@ cat >expected <<\EOF
 100644 X 2     Z/MM
 100644 X 3     Z/MM
 100644 X 0     Z/MN
-100644 X 3     Z/NA
+100644 X 0     Z/NA
 100644 X 1     Z/ND
 100644 X 2     Z/ND
 100644 X 0     Z/NM
@@ -150,7 +150,7 @@ test_expect_success \
     "rm -fr [NDMALTS][NDMALTSF] Z &&
      rm .git/index &&
      git-read-tree $tree_A &&
-     git-checkout-cache -f -u -a &&
+     git-checkout-index -f -u -a &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -218,6 +218,9 @@ currently implemented.
                                            or (2) match B.
  ------------------------------------------------------------------
  15  exists  O==A    O==B      take B      must match A if exists.
+ ------------------------------------------------------------------
+ 16  exists  O==A    O==B      barf        must match A if exists.
+     *multi* in one  in another
 -------------------------------------------------------------------
 
 Note: if we want to implement 2ALT and 3ALT we need to be careful.
@@ -230,45 +233,53 @@ test_expect_failure \
     '1 - must not have an entry not in A.' \
     "rm -f .git/index XX &&
      echo XX >XX &&
-     git-update-cache --add XX &&
+     git-update-index --add XX &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
-test_expect_failure \
-    '2 - must not have an entry not in A.' \
+test_expect_success \
+    '2 - must match B in !O && !A && B case.' \
+    "rm -f .git/index NA &&
+     cp .orig-B/NA NA &&
+     git-update-index --add NA &&
+     git-read-tree -m $tree_O $tree_A $tree_B"
+
+test_expect_success \
+    '2 - matching B alone is OK in !O && !A && B case.' \
     "rm -f .git/index NA &&
      cp .orig-B/NA NA &&
-     git-update-cache --add NA &&
+     git-update-index --add NA &&
+     echo extra >>NA &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
-    '3 - must match and be up-to-date in !O && A && !B case.' \
+    '3 - must match A in !O && A && !B case.' \
     "rm -f .git/index AN &&
      cp .orig-A/AN AN &&
-     git-update-cache --add AN &&
+     git-update-index --add AN &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
-test_expect_failure \
-    '3 (fail) - must match and be up-to-date in !O && A && !B case.' \
+test_expect_success \
+    '3 - matching A alone is OK in !O && A && !B case.' \
     "rm -f .git/index AN &&
      cp .orig-A/AN AN &&
-     git-update-cache --add AN &&
+     git-update-index --add AN &&
      echo extra >>AN &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_failure \
-    '3 (fail) - must match and be up-to-date in !O && A && !B case.' \
+    '3 (fail) - must match A in !O && A && !B case.' \
     "rm -f .git/index AN &&
      cp .orig-A/AN AN &&
      echo extra >>AN &&
-     git-update-cache --add AN &&
+     git-update-index --add AN &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '4 - must match and be up-to-date in !O && A && B && A!=B case.' \
     "rm -f .git/index AA &&
      cp .orig-A/AA AA &&
-     git-update-cache --add AA &&
+     git-update-index --add AA &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -276,7 +287,7 @@ test_expect_failure \
     '4 (fail) - must match and be up-to-date in !O && A && B && A!=B case.' \
     "rm -f .git/index AA &&
      cp .orig-A/AA AA &&
-     git-update-cache --add AA &&
+     git-update-index --add AA &&
      echo extra >>AA &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
@@ -285,59 +296,60 @@ test_expect_failure \
     "rm -f .git/index AA &&
      cp .orig-A/AA AA &&
      echo extra >>AA &&
-     git-update-cache --add AA &&
+     git-update-index --add AA &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
-    '5 - must match and be up-to-date in !O && A && B && A==B case.' \
+    '5 - must match in !O && A && B && A==B case.' \
     "rm -f .git/index LL &&
      cp .orig-A/LL LL &&
-     git-update-cache --add LL &&
+     git-update-index --add LL &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
-test_expect_failure \
-    '5 (fail) - must match and be up-to-date in !O && A && B && A==B case.' \
+test_expect_success \
+    '5 - must match in !O && A && B && A==B case.' \
     "rm -f .git/index LL &&
      cp .orig-A/LL LL &&
-     git-update-cache --add LL &&
+     git-update-index --add LL &&
      echo extra >>LL &&
-     git-read-tree -m $tree_O $tree_A $tree_B"
+     git-read-tree -m $tree_O $tree_A $tree_B &&
+     check_result"
 
 test_expect_failure \
-    '5 (fail) - must match and be up-to-date in !O && A && B && A==B case.' \
+    '5 (fail) - must match A in !O && A && B && A==B case.' \
     "rm -f .git/index LL &&
      cp .orig-A/LL LL &&
      echo extra >>LL &&
-     git-update-cache --add LL &&
+     git-update-index --add LL &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_failure \
     '6 - must not exist in O && !A && !B case' \
     "rm -f .git/index DD &&
      echo DD >DD
-     git-update-cache --add DD &&
+     git-update-index --add DD &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_failure \
     '7 - must not exist in O && !A && B && O!=B case' \
     "rm -f .git/index DM &&
      cp .orig-B/DM DM &&
-     git-update-cache --add DM &&
+     git-update-index --add DM &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_failure \
     '8 - must not exist in O && !A && B && O==B case' \
     "rm -f .git/index DN &&
      cp .orig-B/DN DN &&
-     git-update-cache --add DN &&
+     git-update-index --add DN &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '9 - must match and be up-to-date in O && A && !B && O!=A case' \
     "rm -f .git/index MD &&
      cp .orig-A/MD MD &&
-     git-update-cache --add MD &&
+     git-update-index --add MD &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -345,7 +357,7 @@ test_expect_failure \
     '9 (fail) - must match and be up-to-date in O && A && !B && O!=A case' \
     "rm -f .git/index MD &&
      cp .orig-A/MD MD &&
-     git-update-cache --add MD &&
+     git-update-index --add MD &&
      echo extra >>MD &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
@@ -354,14 +366,14 @@ test_expect_failure \
     "rm -f .git/index MD &&
      cp .orig-A/MD MD &&
      echo extra >>MD &&
-     git-update-cache --add MD &&
+     git-update-index --add MD &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '10 - must match and be up-to-date in O && A && !B && O==A case' \
     "rm -f .git/index ND &&
      cp .orig-A/ND ND &&
-     git-update-cache --add ND &&
+     git-update-index --add ND &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -369,7 +381,7 @@ test_expect_failure \
     '10 (fail) - must match and be up-to-date in O && A && !B && O==A case' \
     "rm -f .git/index ND &&
      cp .orig-A/ND ND &&
-     git-update-cache --add ND &&
+     git-update-index --add ND &&
      echo extra >>ND &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
@@ -378,14 +390,14 @@ test_expect_failure \
     "rm -f .git/index ND &&
      cp .orig-A/ND ND &&
      echo extra >>ND &&
-     git-update-cache --add ND &&
+     git-update-index --add ND &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '11 - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \
     "rm -f .git/index MM &&
      cp .orig-A/MM MM &&
-     git-update-cache --add MM &&
+     git-update-index --add MM &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -393,7 +405,7 @@ test_expect_failure \
     '11 (fail) - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \
     "rm -f .git/index MM &&
      cp .orig-A/MM MM &&
-     git-update-cache --add MM &&
+     git-update-index --add MM &&
      echo extra >>MM &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
@@ -402,14 +414,14 @@ test_expect_failure \
     "rm -f .git/index MM &&
      cp .orig-A/MM MM &&
      echo extra >>MM &&
-     git-update-cache --add MM &&
+     git-update-index --add MM &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '12 - must match A in O && A && B && O!=A && A==B case' \
     "rm -f .git/index SS &&
      cp .orig-A/SS SS &&
-     git-update-cache --add SS &&
+     git-update-index --add SS &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -417,7 +429,7 @@ test_expect_success \
     '12 - must match A in O && A && B && O!=A && A==B case' \
     "rm -f .git/index SS &&
      cp .orig-A/SS SS &&
-     git-update-cache --add SS &&
+     git-update-index --add SS &&
      echo extra >>SS &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
@@ -427,14 +439,14 @@ test_expect_failure \
     "rm -f .git/index SS &&
      cp .orig-A/SS SS &&
      echo extra >>SS &&
-     git-update-cache --add SS &&
+     git-update-index --add SS &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '13 - must match A in O && A && B && O!=A && O==B case' \
     "rm -f .git/index MN &&
      cp .orig-A/MN MN &&
-     git-update-cache --add MN &&
+     git-update-index --add MN &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -442,7 +454,7 @@ test_expect_success \
     '13 - must match A in O && A && B && O!=A && O==B case' \
     "rm -f .git/index MN &&
      cp .orig-A/MN MN &&
-     git-update-cache --add MN &&
+     git-update-index --add MN &&
      echo extra >>MN &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
@@ -451,7 +463,16 @@ test_expect_success \
     '14 - must match and be up-to-date in O && A && B && O==A && O!=B case' \
     "rm -f .git/index NM &&
      cp .orig-A/NM NM &&
-     git-update-cache --add NM &&
+     git-update-index --add NM &&
+     git-read-tree -m $tree_O $tree_A $tree_B &&
+     check_result"
+
+test_expect_success \
+    '14 - may match B in O && A && B && O==A && O!=B case' \
+    "rm -f .git/index NM &&
+     cp .orig-B/NM NM &&
+     git-update-index --add NM &&
+     echo extra >>NM &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -459,7 +480,7 @@ test_expect_failure \
     '14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \
     "rm -f .git/index NM &&
      cp .orig-A/NM NM &&
-     git-update-cache --add NM &&
+     git-update-index --add NM &&
      echo extra >>NM &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
@@ -468,14 +489,14 @@ test_expect_failure \
     "rm -f .git/index NM &&
      cp .orig-A/NM NM &&
      echo extra >>NM &&
-     git-update-cache --add NM &&
+     git-update-index --add NM &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
 test_expect_success \
     '15 - must match A in O && A && B && O==A && O==B case' \
     "rm -f .git/index NN &&
      cp .orig-A/NN NN &&
-     git-update-cache --add NN &&
+     git-update-index --add NN &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
 
@@ -483,7 +504,7 @@ test_expect_success \
     '15 - must match A in O && A && B && O==A && O==B case' \
     "rm -f .git/index NN &&
      cp .orig-A/NN NN &&
-     git-update-cache --add NN &&
+     git-update-index --add NN &&
      echo extra >>NN &&
      git-read-tree -m $tree_O $tree_A $tree_B &&
      check_result"
@@ -493,7 +514,20 @@ test_expect_failure \
     "rm -f .git/index NN &&
      cp .orig-A/NN NN &&
      echo extra >>NN &&
-     git-update-cache --add NN &&
+     git-update-index --add NN &&
      git-read-tree -m $tree_O $tree_A $tree_B"
 
+# #16
+test_expect_success \
+    '16 - A matches in one and B matches in another.' \
+    'rm -f .git/index F16 &&
+    echo F16 >F16 &&
+    git-update-index --add F16 &&
+    tree0=`git-write-tree` &&
+    echo E16 >F16 &&
+    git-update-index F16 &&
+    tree1=`git-write-tree` &&
+    git-read-tree -m $tree0 $tree1 $tree1 $tree0 &&
+    git-ls-files --stage'
+
 test_done