From: Seth House Date: Wed, 18 Aug 2010 03:22:58 GMT Subject: Re: Conflict markers in mergetool $LOCAL ? Message-ID: In-Reply-To: <4C6AFE09.5020302@hashpling.org> Charles Bailey hashpling.org> writes: > Most 3-way merge tools use BASE, LOCAL and REMOTE That is how Mercurial invokes vimdiff, except it also uses a wrapper shell script in order to tell vimdiff where to save the final edit. That said, you're right that vimdiff doesn't do the "good semi-automatic conflict resolution" that you spoke of. > I personally have used and would recommend kdiff3 I spent some time playing with kdiff3 today. Thanks for the recommendation. I now understand why a merge tool that has native support for comparing all four file versions ($BASE, $LOCAL, $REMOTE, and $MERGED) is vastly more powerful than tools that don't (vimdiff, Meld) -- and I wish that bit of information would make it into more diff-tool comparisons discussions online. So, back to my OP, most of the time I deal with tiny conflicts. I wanted a quick way to look at *only* the conflicts without having to do the search-next-search-next dance with my editor -- which is something that vimdiff can do very well. In case anyone stumbles on to this thread looking for something similar, I settled on the script below. Thanks for your help/advice, David, Jacob, and Charles! #!/bin/sh # Use vimdiff to quickly go through Git merge conflicts. # # Save your changes to the LOCAL file. MERGED will be updated if # vimdiff exits cleanly. Use :cq to abort. # # Put the following in your ~/.gitconfig # # [mergetool "vimdiffconflicts"] # cmd = unmerge.sh $BASE $LOCAL $REMOTE $MERGED # trustExitCode = true if [[ -z $@ || $# != "4" ]] ; then echo -e "Usage: $0 \$BASE \$LOCAL \$REMOTE \$MERGED" exit 1 fi BASE=$1 LOCAL=$2 REMOTE=$3 MERGED=$4 sed -e '/<<<<<<>>>>>>/d' $MERGED > $LOCAL sed -e '/=======/,/>>>>>>>/d' -e '/<<<<<< $REMOTE vim -f -d $BASE $LOCAL $REMOTE \ -c ':diffoff' -c ':set scrollbind' -c 'wincmd l' EC=$? # Overwrite $MERGED [[ $EC == "0" ]] && cat $LOCAL > $MERGED exit $EC