git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Conflict markers in mergetool $LOCAL ?

From
Seth House <seth@eseth.com>
Date
Aug 18, 2010, 03:22 UTC
Message-ID
<loom.20100818T052242-649@post.gmane.org>
In-Reply-To
<4C6AFE09.5020302@hashpling.org>
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
Previous: Charles Bailey
Message 8 of 8 in “Conflict markers in mergetool $LOCAL ?”
  1. Seth HouseAug 17, 2010
  2. David AguilarAug 17, 2010
  3. David AguilarAug 17, 2010
  4. Seth HouseAug 17, 2010
  5. Jacob HelwigAug 17, 2010
  6. Seth HouseAug 17, 2010
  7. Charles BaileyAug 17, 2010
  8. Seth HouseAug 18, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.