问题
I currently use RCS' merge command to do 3-way merges, but one thing has always annoyed me about it. If I use the -A option, the same change made in both files shows up as a conflict:
<<<<<<< file1
file1 line 1
||||||| orig
orig line 1
=======
file2 line 1
>>>>>>> file2
orig line 2
<<<<<<< orig
=======
line added in both changes
>>>>>>> file2
orig line 3
If I use the default (-E) then those identical changes are not shown, but then the ouput only shows the two contributors, not the ancestor, something like this:
<<<<<<< file1
file1 line 1
=======
file2 line 1
>>>>>>> file2
orig line 2
line added in both changes
orig line 3
Is there some program that will essentially do the same behaviour as RCS merge but has some way of showing all three versions in conflicts while automatically merging identical changes?
回答1:
Looks like diff3 has some interesting options.
On ubuntu:
-m --merge Output merged file instead of ed script (default -A).
You asked for non-graphical, but vimdiff and gvimdiff can do 3 adjacent windows.
回答2:
KDiff3 is graphical, but it does have an "--auto" option that, when called from the command line, will perform the merge and show the GUI only if a conflict occurs. I know that means you still need a GUI, but kdiff3 can still be useful from the command line. I use it that way all the time (on Windows - not sure about other versions).
(I wanted to add this comment to the other KDiff3 post, but couldn't work out how to do it - sorry.)
来源:https://stackoverflow.com/questions/379593/non-graphical-3-way-merge-tool