summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8544a6f)
raw | patch | inline | side by side (parent: 8544a6f)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 8 Jun 2005 21:55:35 +0000 (14:55 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Wed, 8 Jun 2005 22:56:09 +0000 (15:56 -0700) |
This adds a set of tests to make sure that requirements on
existing cache entries are checked when a read-tree -m 3-way
merge is run with an already populated index file.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
existing cache entries are checked when a read-tree -m 3-way
merge is run with an already populated index file.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
t/lib-read-tree-m-3way.sh | patch | blob | history | |
t/t1000-read-tree-m-3way.sh | patch | blob | history |
index d920c6b3a3bfbb5994244a78d1ad99ce02748122..d6645b4f42f287c7572f0f868868739eb9908fb6 100644 (file)
'recording branch B tree' \
'tree_B=$(git-write-tree)'
+test_expect_success \
+ 'keep contents of 3 trees for easy access' \
+ 'rm -f .git/index &&
+ git-read-tree $tree_O &&
+ mkdir .orig-O &&
+ git-checkout-cache --prefix=.orig-O/ -f -q -a &&
+ rm -f .git/index &&
+ git-read-tree $tree_A &&
+ mkdir .orig-A &&
+ git-checkout-cache --prefix=.orig-A/ -f -q -a &&
+ rm -f .git/index &&
+ git-read-tree $tree_B &&
+ mkdir .orig-B &&
+ git-checkout-cache --prefix=.orig-B/ -f -q -a'
index d18f8cbcf4ebc328b4c8d761735f479a7d27d0ed..c43588727b27f600b6a8ad1443981aaadea72590 100755 (executable)
. ../lib-read-tree-m-3way.sh
################################################################
-# Try merging and showing the various diffs
+# This is the "no trivial merge unless all three exists" table.
cat >expected <<\EOF
100644 X 2 AA
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
-# The tree is dirty at this point.
-test_expect_failure \
- '3-way merge with git-read-tree -m, dirty cache' \
- "git-read-tree -m $tree_O $tree_A $tree_B"
+check_result () {
+ git-ls-files --stage | sed -e 's/ '"$_x40"' / X /' >current &&
+ diff -u expected current
+}
# This is done on an empty work directory, which is the normal
# merge person behaviour.
"rm -fr [NDMALTS][NDMALTSF] Z &&
rm .git/index &&
git-read-tree -m $tree_O $tree_A $tree_B &&
- git-ls-files --stage |
- sed -e 's/ $_x40 / X /' >current &&
- diff -u expected current"
+ check_result"
# This starts out with the first head, which is the normal
# patch submitter behaviour.
test_expect_success \
'3-way merge with git-read-tree -m, match H' \
- "git-read-tree $tree_A &&
+ "rm -fr [NDMALTS][NDMALTSF] Z &&
+ rm .git/index &&
+ git-read-tree $tree_A &&
git-checkout-cache -f -u -a &&
git-read-tree -m $tree_O $tree_A $tree_B &&
- git-ls-files --stage |
- sed -e 's/ $_x40 / X /' >current &&
- diff -u expected current"
+ check_result"
+
+: <<\END_OF_CASE_TABLE
+
+We have so far tested only empty index and clean-and-matching-A index
+case which are trivial. Make sure index requirements are also
+checked. The table also lists alternative semantics which is not
+currently implemented.
+
+"git-diff-tree -m O A B"
+
+ O A B result index requirements
+-------------------------------------------------------------------
+ 1 missing missing missing - must not exist.
+ ------------------------------------------------------------------
+ 2 missing missing exists no merge must not exist.
+ ------------------------------------
+ (ALT) take B* must match B, if exists.
+ ------------------------------------------------------------------
+ 3 missing exists missing no merge must match A and be
+ up-to-date, if exists.
+ ------------------------------------
+ (ALT) take A* must match A, if exists.
+ ------------------------------------------------------------------
+ 4 missing exists A!=B no merge must match A and be
+ up-to-date, if exists.
+ ------------------------------------------------------------------
+ 5 missing exists A==B no merge must match A and be
+ up-to-date, if exists.
+ ------------------------------------
+ (ALT) take A must match A, if exists.
+ ------------------------------------------------------------------
+ 6 exists missing missing no merge must not exist.
+ ------------------------------------
+ (ALT) remove must not exist.
+ ------------------------------------------------------------------
+ 7 exists missing O!=B no merge must not exist.
+ ------------------------------------------------------------------
+ 8 exists missing O==B no merge must not exist.
+ ------------------------------------
+ (ALT) remove must not exist.
+ ------------------------------------------------------------------
+ 9 exists O!=A missing no merge must match A and be
+ up-to-date, if exists.
+ ------------------------------------------------------------------
+ 10 exists O==A missing no merge must match A and be
+ up-to-date, if exists.
+ ------------------------------------
+ (ALT) remove ditto
+ ------------------------------------------------------------------
+ 11 exists O!=A O!=B no merge must match A and be
+ A!=B up-to-date, if exists.
+ ------------------------------------------------------------------
+ 12 exists O!=A O!=B take A must match A, if exists.
+ A==B
+ ------------------------------------------------------------------
+ 13 exists O!=A O==B take A must match A, if exists.
+ ------------------------------------------------------------------
+ 14 exists O==A O!=B take B must match A and be
+ be up-to-date, if exists.
+ ------------------------------------
+ (ALT) take B if exists, must either (1)
+ match A and be up-to-date,
+ or (2) match B.
+ ------------------------------------------------------------------
+ 15 exists O==A O==B take B must match A if exists.
+-------------------------------------------------------------------
+
+Note: if we want to implement 2ALT and 3ALT we need to be careful.
+The tree A may contain DF (file) when tree B require DF to be a
+directory by having DF/DF (file).
+
+END_OF_CASE_TABLE
+
+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-read-tree -m $tree_O $tree_A $tree_B"
+
+test_expect_failure \
+ '2 - must not have an entry not in A.' \
+ "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 \
+ '3 - must match and be up-to-date 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.' \
+ "rm -f .git/index AN &&
+ cp .orig-A/AN AN &&
+ git-update-cache --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.' \
+ "rm -f .git/index AN &&
+ cp .orig-A/AN AN &&
+ echo extra >>AN &&
+ git-update-cache --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-read-tree -m $tree_O $tree_A $tree_B &&
+ check_result"
+
+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 &&
+ echo extra >>AA &&
+ git-read-tree -m $tree_O $tree_A $tree_B"
+
+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 &&
+ echo extra >>AA &&
+ git-update-cache --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.' \
+ "rm -f .git/index LL &&
+ cp .orig-A/LL LL &&
+ git-update-cache --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.' \
+ "rm -f .git/index LL &&
+ cp .orig-A/LL LL &&
+ git-update-cache --add LL &&
+ echo extra >>LL &&
+ git-read-tree -m $tree_O $tree_A $tree_B"
+
+test_expect_failure \
+ '5 (fail) - must match and be up-to-date 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-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-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-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-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-read-tree -m $tree_O $tree_A $tree_B &&
+ check_result"
+
+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 &&
+ echo extra >>MD &&
+ git-read-tree -m $tree_O $tree_A $tree_B"
+
+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 &&
+ echo extra >>MD &&
+ git-update-cache --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-read-tree -m $tree_O $tree_A $tree_B &&
+ check_result"
+
+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 &&
+ echo extra >>ND &&
+ git-read-tree -m $tree_O $tree_A $tree_B"
+
+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 &&
+ echo extra >>ND &&
+ git-update-cache --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-read-tree -m $tree_O $tree_A $tree_B &&
+ check_result"
+
+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 &&
+ echo extra >>MM &&
+ git-read-tree -m $tree_O $tree_A $tree_B"
+
+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 &&
+ echo extra >>MM &&
+ git-update-cache --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-read-tree -m $tree_O $tree_A $tree_B &&
+ check_result"
+
+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 &&
+ echo extra >>SS &&
+ git-read-tree -m $tree_O $tree_A $tree_B &&
+ check_result"
+
+test_expect_failure \
+ '12 (fail) - must match A in O && A && B && O!=A && A==B case' \
+ "rm -f .git/index SS &&
+ cp .orig-A/SS SS &&
+ echo extra >>SS &&
+ git-update-cache --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-read-tree -m $tree_O $tree_A $tree_B &&
+ check_result"
+
+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 &&
+ echo extra >>MN &&
+ git-read-tree -m $tree_O $tree_A $tree_B &&
+ check_result"
+
+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-read-tree -m $tree_O $tree_A $tree_B &&
+ check_result"
+
+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 &&
+ echo extra >>NM &&
+ git-read-tree -m $tree_O $tree_A $tree_B"
+
+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 &&
+ echo extra >>NM &&
+ git-update-cache --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-read-tree -m $tree_O $tree_A $tree_B &&
+ check_result"
+
+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 &&
+ echo extra >>NN &&
+ git-read-tree -m $tree_O $tree_A $tree_B &&
+ check_result"
+
+test_expect_failure \
+ '15 (fail) - must match A in O && A && B && O==A && O==B case' \
+ "rm -f .git/index NN &&
+ cp .orig-A/NN NN &&
+ echo extra >>NN &&
+ git-update-cache --add NN &&
+ git-read-tree -m $tree_O $tree_A $tree_B"
test_done