Proposal for new git Merge Strategy
Folks,
The other day, I was talking to some other folks else-list about git's approach to merges and mentioned that there was some structure in place to handle different merge strategies.
One person observed that Perforce had a really good approach to merging and conflict resolution that allowed user interaction during the process specifically to help select the individual files and hunks that contributed to the final result. I confess that I have never used Perforce, so this is all hear-say and interpretation. :-)
However, it does seem like an approach that we could easily add to git -- not as the default of course. (Just think how dead we'd all be if Linus had to manually interact with every merge he performed at the tip of the Linux Pyramid. :-)
But for complex or critical merges, a "guided merge" strategy seems like it might be a useful tool. Basically, it would offer options to select Stage 1 or Stage 2 revisions, or step in and offer hunks from Stage 1 and 2, revert to "ours" or "theirs", or "revert to 'ours' or 'theirs' for all remaining files". Things like that maybe.
Any thoughts down this line? Good idea? Bad idea?
Thanks,
jdl
PS -- Please keep mwm on the CC: list as he doesn't
directly subscribe to the git list, but would like to participate in the thread. Thanks!
Quoted 8 lines · Jon Loeliger
But for complex or critical merges, a "guided merge" strategy seems like it might be a useful tool. Basically, it would offer options to select Stage 1 or Stage 2 revisions, or step in and offer hunks from Stage 1 and 2, revert to "ours" or "theirs", or "revert to 'ours' or 'theirs' for all remaining files". Things like that maybe.
Any thoughts down this line? Good idea? Bad idea?
We had some discussion on this with Catalin in "Unresolved issues #3" thread, regarding git-xxdiff (did I ever take it? I liked it for what it does, but I was not sure about its odd-man-out-ness) which was proposed by Martin Langhoff.
A merge that results in manual fixups conceptually take these steps:
- revs involved in 3-way merge identified with git-merge-base;
- read-tree is given these three bases;
- git-merge-index gives three stages as individual temporary files to git-merge-one-file for each path that cannot be resolved at tree-level.
- git-merge-one-file calls "merge" (reminds me that I should replace this with "diff3").
We should be able to make the part that call "merge/diff3" to alternatively call xxdiff or its friends (kompare, emerge, pick your favorites). Catalin even showed us a code snippet used in StGIT for this in the thread.
Martin's proposed tool git-xxdiff is meant to be invoked after all of the above still left conflict markers. As Catalin pointed out, using "xxdiff -U" to work on a file with conflict markers is less powerful than working on three stages directly, but on the other hand it can be used as the last stage fixup, independent from what git-merge does internally. In other words, it is meant to help solving the same problem but in a different part of the workflow.
Quoted 1 line · Junio C Hamano
Jon Loeliger <[email protected]> writes:
...
Quoted 6 lines
Quoted 1 line
Any thoughts down this line? Good idea? Bad idea?
We had some discussion on this with Catalin in "Unresolved issues #3" thread, regarding git-xxdiff (did I ever take it? I liked it for what it does, but I was not sure about its odd-man-out-ness) which was proposed by Martin Langhoff.
I've been slack on my reading of the list lately so totally missed out on that thread. I'll go and read it now...
...
Quoted 4 lines
We should be able to make the part that call "merge/diff3" to alternatively call xxdiff or its friends (kompare, emerge, pick your favorites). Catalin even showed us a code snippet used in StGIT for this in the thread.
I still think that the default initial behaviour git has is right. Most conflicts are trivial, and people can deal with conflict markers just right. It's what we are used to.
Except when it's a mess and it's unclear what goes where and why. That's when git log --merge and my git-xxdiff help. I've also been wondering if I can do gitk --merge easily ;-)
Quoted 8 lines
Martin's proposed tool git-xxdiff is meant to be invoked after all of the above still left conflict markers. As Catalin pointed out, using "xxdiff -U" to work on a file with conflict markers is less powerful than working on three stages directly, but on the other hand it can be used as the last stage fixup, independent from what git-merge does internally. In other words, it is meant to help solving the same problem but in a different part of the workflow.
My implementation doesn't use the 3 stages either, just because I didn't see xxdiff giving any stage a particular meaning. I should rework it to have the 3 stages there, and trust users to read the filename, which should say 'ancestor'.
In terms of the one script or many, if there is concensus on OneScriptToRuleThemAll, I am not that opposed to reworking it to something like
git-mergehelper --tool xxdiff path/to/file.c
with a big switch statement inside the script :-p What bothers me is that there may be interesting parameters to pass to the invoked tool, and other than having a stupid '--toolopts' passthrough, we are pretty fsck'd.
By having separate git-xxdiff, git-meld, etc the git- scripts would accept all/most of the same params that the tool accepts, therefore feeling "natural" to users of the tool. A definite advantage, IMHO.
{Ugh, my implementation doesn't get that far. But hey, good intentions!}
cheers,
martin
Quoted 17 lines · Jon Loeliger
The other day, I was talking to some other folks else-list about git's approach to merges and mentioned that there was some structure in place to handle different merge strategies.
One person observed that Perforce had a really good approach to merging and conflict resolution that allowed user interaction during the process specifically to help select the individual files and hunks that contributed to the final result. I confess that I have never used Perforce, so this is all hear-say and interpretation. :-)
However, it does seem like an approach that we could easily add to git -- not as the default of course. (Just think how dead we'd all be if Linus had to manually interact with every merge he performed at the tip of the Linux Pyramid. :-)
Quoted 6 lines
But for complex or critical merges, a "guided merge" strategy seems like it might be a useful tool. Basically, it would offer options to select Stage 1 or Stage 2 revisions, or step in and offer hunks from Stage 1 and 2, revert to "ours" or "theirs", or "revert to 'ours' or 'theirs' for all remaining files". Things like that maybe.
And select which files are which (after renaming, copying, etc.)
Quoted 1 line
Any thoughts down this line? Good idea? Bad idea?
Wouldn't it be better to fallback to graphical/user guided merger only on _failed_ merge? Merge helpers like xxdiff, Meld or KDiff3
http://git.or.cz/gitwiki/InterfacesFrontendsAndToolsWishlist
There was proposal of git script which run xxdiff with correct extracted files, if I remeber correctly postponed waiting for more generic version.
Signature · 3 lines
Jakub Narebski Warsaw, Poland ShadeHawk on #git