merge-conflicts
merge-conflicts copied to clipboard
Expand conflict detection to support different files using git diff
(This is an enhancement request. Apologies if it's outside the scope of development.)
This package could leverage the already stellar merge interface and the git diff command to allow the user to compare and merge two different versions of a file even if outside the repository (--no-index flag).
This would make it easier to manually copy changes from one file to another and merge changes to production files.
Huh, that's a cool idea. I didn't even know you could do that.
Can you give more details on how this would work, exactly? This is my first thought:
- Open file A in an editor.
- Invoke
merge-conflicts:manual-compare(or whatever) - Choose file B from a dialog.
- Run something like
git diff --no-index file-a file-b > file-a( :question: ) - Detect "conflicts" now marked in file A and allow "resolution"
That sounds right. Alternatively you could right click a file and have 'Compare with current file' in the context menu.
Unfortunately I can't seem to make git diff output '<<<' conflict markers instead of '-' and '+' lines, so I guess some additional work would be required in terms of modification detection.
Unfortunately I can't seem to make git diff output '<<<' conflict markers instead of '-' and '+' lines, so I guess some additional work would be required in terms of modification detection.
Ah - that is a problem.
git's merge process uses a three-way diff (with a common ancestor) rather than a two-way diff to produce its output -- it's one of the reasons merging in git is as smooth as it is. git diff by necessity will be only two-way. I wonder if there's some way you can invoke a plumbing-level command for the merge machinery and manually supply the three inputs. (This came up in #43, too.) Of course, then you have the question of what you use as the "common ancestor..."
What about using
git merge-file -p file1.txt ancestor.txt file2.txt
I tried using an empty file as ancestor and the output seems to be the expected one. More documentation: http://git-scm.com/docs/git-merge-file
Nice! That's just what I was hoping for (and hadn't had time to look for). :metal:
I tried using an empty file as ancestor and the output seems to be the expected one.
:+1: