aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-06-11 02:50:51 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-12 20:40:20 -0700
commit32192e6622d78347448cfc0572827d6e64e0de28 (patch)
tree460a1aa7e3734888a6e25721c11e39deede40084 /t
parente7f9bc411c8519468c33e1d882fb02cbe9c1ea55 (diff)
downloadgit-32192e6622d78347448cfc0572827d6e64e0de28.tar.gz
git-32192e6622d78347448cfc0572827d6e64e0de28.tar.xz
[PATCH] Finish making --emu23 equivalent to pure 2-way merge.
This adds #3ALT rule (and #2ALT rule for symmetry) to the read-tree 3-way merge logic that collapses paths that are added only in one branch and not in the other internally. This makes --emu23 to succeed in the last remaining case where the pure 2-way merge succeeded and earlier one failed. Running diff between t1001 and t1005 test scripts shows that the only difference between the two is that --emu23 can leave the states into separate stages so that the user can use usual 3-way merge resolution techniques to carry forward the local changes when pure 2-way merge would have refused to run. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 't')
-rwxr-xr-xt/t1000-read-tree-m-3way.sh32
-rw-r--r--t/t1005-read-tree-m-2way-emu23.sh20
2 files changed, 36 insertions, 16 deletions
diff --git a/t/t1000-read-tree-m-3way.sh b/t/t1000-read-tree-m-3way.sh
index 92833fe95..3d9b3ac9b 100755
--- a/t/t1000-read-tree-m-3way.sh
+++ b/t/t1000-read-tree-m-3way.sh
@@ -75,13 +75,13 @@ In addition:
. ../lib-read-tree-m-3way.sh
################################################################
-# Trivial "majority when 3 stages exist" merge plus #5ALT trivial
-# merge.
+# 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
@@ -96,7 +96,7 @@ cat >expected <<\EOF
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
@@ -233,23 +233,31 @@ test_expect_failure \
git-update-cache --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-cache --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 &&
+ 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-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 &&
@@ -257,7 +265,7 @@ test_expect_failure \
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 &&
diff --git a/t/t1005-read-tree-m-2way-emu23.sh b/t/t1005-read-tree-m-2way-emu23.sh
index 495642e08..bb955ed39 100644
--- a/t/t1005-read-tree-m-2way-emu23.sh
+++ b/t/t1005-read-tree-m-2way-emu23.sh
@@ -80,6 +80,17 @@ test_expect_success \
git-ls-tree $treeM &&
git-diff-tree $treeH $treeM'
+# "read-tree -m H I+H M" but I is empty so this is "read-tree -m H H M".
+#
+# bozbar [O && A && B && O==A && O!=B (#14) ==> B] take M by read-tree
+# frotz [!O && !A && B (#2) ==> B] take M by read-tree
+# nitfol [O && A && B && O==A && O==B (#15) ==> B] take M by read-tree
+# rezrov [O && A && !B && O==A (#10) ==> no merge] removed by script
+#
+# Earlier one did not have #2ALT so taking M was done by the script,
+# which also updated the work tree and making frotz clean. With #2ALT,
+# this is resolved by read-tree itself and the path is left dirty
+# because we are not testing "read-tree -u --emu23".
test_expect_success \
'1, 2, 3 - no carry forward' \
'rm -f .git/index &&
@@ -87,7 +98,7 @@ test_expect_success \
git-ls-files --stage >1-3.out &&
diff -u M.out 1-3.out &&
check_cache_at bozbar dirty &&
- check_cache_at frotz clean && # different from pure 2-way
+ check_cache_at frotz dirty && # same as pure 2-way again.
check_cache_at nitfol dirty'
echo '+100644 X 0 yomin' >expected
@@ -103,8 +114,8 @@ test_expect_success \
check_cache_at yomin clean'
# "read-tree -m H I+H M" where !H && !M; so (I+H) not being up-to-date
-# should not matter, but without #3ALT this does not work.
-: test_expect_success \
+# should not matter. Thanks to #3ALT, this is now possible.
+test_expect_success \
'5 - carry forward local addition.' \
'rm -f .git/index &&
echo yomin >yomin &&
@@ -218,6 +229,7 @@ test_expect_success \
# This is different from straight 2-way merge in that it leaves
# three stages of bozbar in the index file without failing, so
# the user can run git-diff-stages to examine the situation.
+# With #2ALT, frotz is resolved internally.
test_expect_success \
'16 - conflicting local change.' \
'rm -f .git/index &&
@@ -228,7 +240,7 @@ test_expect_success \
100644 X 1 bozbar
100644 X 2 bozbar
100644 X 3 bozbar
-100644 X 3 frotz
+100644 X 0 frotz
100644 X 0 nitfol
100644 X 1 rezrov
100644 X 2 rezrov