#!/bin/bash # # this patch can be found here: # http://www.jukie.net/~bart/scripts/tmp/vimdiff-on-git-merge-conflict # # this script uses git-cat, inspired by cg-admin-cat, it can be found here: # http://www.jukie.net/~bart/scripts/tmp/git-cat # # use case: you do a git pull and you have a merge conflict. you want to review # all the chagnes and decide what to do for each conflict. This script runs # a 3 way vimdiff over each of the files that is in conflict; the three # views are local file, merged/in-conflict file, and remote file. You select # which deltas you want with 'do' (see :help do in vim), or edit the middle # pane manually. # # NOTE: this script will only work if the following conditions are met # .git/ORIG_HEAD - the HEAD before the merge started # .git/MERGE_HEAD - the commit ID we pulled / merged in # git status | grep unmerged - a non empty list of files that need merging # set -u -e # defaults do_debug= be_verbose= do_am_merge= do_status_only= do_gitk_only= conflict_markers="^\(<<<<<<<\|=======\|>>>>>>>\)" prog=$(basename $0) USAGE="$prog [-h]" function bail { rc=$1 ; shift ((to=(rc?2:1))) echo $@ >&$to exit $rc } function warn { echo $@ >&2 } function vecho { [ -z "$be_verbose" ] || echo $@ >&2 } function help { rc=$1 ; shift ((to=($rc?2:1))) cat >&$to <