From: Bram Cohen Date: 2005-04-28 06:25:18 Archived: http://www.gelato.unsw.edu.au/archives/git/0504/2279.html Here's an example of where simple three-way merge can't do the right thing. Each letter represents a snapshot of the history, and time goes downwards. The numbers after some letters refer to which line number was modified at that time. A |\ | \ | \ | \ | \ | \ | \ B8 C3 |\ /| | \ / | | \ / | | X | | / \ | | / \ | |/ \| D8 E3 \ | \ | \ | \ | \ | \ | \| ? In this case the ? should have a clean merge with the D vesion of line 8 (because it was made with the B version already in the history) and the E version of line 3 (because it was made with the C version already in the history). The problem is that there's no single ancestor for the three-way merge which does the right thing. If one picks B, then there will be an unnecessary merge conflict at line 3, because D will have the C version and E will have the E version but B will have neither. Likewise if one picks C, there will be an unnecessary conflict at line 8 because D will have the D version and E will have the B version but C will have neither. Picking A will cause unnecessary conflicts on *both* lines. The problem can actually be much worse than a simple unnecesary conflict, because if the later updates were strict undos of the earlier updates, then picking either B or C will merge something *wrong*. Using A as the ancestor will keep that from happening, but it also maximizes unnecessary conflicts. Note that the above criss-cross case only involves two branches, using the methodology of each one modifying their own section and pulling in old versions of the other one from time to time. Cogito's interface encourages exactly this work flow, which is not a bad thing from a work flow perspective, but does make it hit this case regularly. The way Git handles this currently is very bad, because it forces the common ancestor to be from the same snapshot across all files, so this problem will happen if the modifications are made even in different files, not just different lines within the same file. That could be improved greatly by finding an LCA for each file individually, which is what Monotone does. Darcs, Codeville, and all the Arch descendants have better merge algorithms which don't have to pick a single common ancestor. -Bram