Re: Conflict markers in mergetool $LOCAL ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Charles Bailey <charles <at> 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' -e '/>>>>>>>/d' $MERGED > $LOCAL
sed -e '/=======/,/>>>>>>>/d' -e '/<<<<<<</d' $MERGED > $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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]