3-way read-tree case matrix.
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:41:59
quoted
quoted
quoted
quoted
"LT" == Linus Torvalds [off-list ref] writes:
LT> I did. It looks fine, although I'd like to point out that even the
LT> three-way merge _does_ mix in the original state for the case where the
LT> merge was trivially resolved...
Thanks. I have another request for sanity checking.
I am not sure if salvaging a dirty tree in a 3-way merge (as
opposed to just downright refusing) would have as much practical
value as the 2-tree fast-forward case, but here is a proposed
case matrix for the 3-way merge.
"git-diff-tree -m O H M"
O H M result index requirements
------------------------------------------------------------------
1 missing missing missing - must not exist.
-----------------------------------------------------------------
2 missing missing exists take M must match M if exists.
-----------------------------------------------------------------
3 missing exists missing remove must match H and be
up-to-date, if exists.
-----------------------------------------------------------------
4 missing exists exists no merge must match H and be
up-to-date, if exists.
-----------------------------------------------------------------
5 exists missing missing no merge must not exist.
-----------------------------------------------------------------
6 exists missing O==M remove must not exist.
-----------------------------------------------------------------
7 exists missing O!=M no merge must not exist.
-----------------------------------------------------------------
8 exists O==H missing remove must match H and be
up-to-date, if exists.
-----------------------------------------------------------------
9 exists O!=H missing no merge must match H and be
up-to-date, if exists.
-----------------------------------------------------------------
10 exists O!=H O!=M no merge must match H and be
up-to-date, if exists.
-----------------------------------------------------------------
11 exists O!=H O==M take H must match H, if exists.
-----------------------------------------------------------------
12 exists O==H O!=M take M if exists, must either (1)
match H and be up-to-date,
or (2) match M.
-----------------------------------------------------------------
13 exists O==H O==M take M must match H if exists.
------------------------------------------------------------------
In all "take H" or "take M" cases, if the original index matches
what is taken, I would reuse it, and keep it dirty if it is.
The goal is, "(1) do not clobber the current index; (2) arrive
at the same result as in the case started with an empty index;
(3) favor success over failure as long as (1) and (2) are
satisfied".