Created
February 1, 2016 22:09
-
-
Save nobrowser/667c21d243aa040d2a74 to your computer and use it in GitHub Desktop.
Interactive 3 way merge a la git, for use as unison merge tool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh -Cefu | |
PATH=/bin:/usr/bin:/usr/local/bin | |
EDITOR=${VISUAL:-emacs} | |
# interactive merge a la git | |
# first, dump marked differences into a temporary file. | |
# ignore the exit status which just means conflicts have been found | |
t=$( mktemp idiff3.XXXXXXXXXXXX ) | |
diff3 --label=local --label=old --label=remote -m $1 $2 $3 >> $t || true | |
# next, interactively edit the marked file | |
"${EDITOR}" $t | |
# hacky but simple: nonempty temp file means signed off | |
size=$( stat --printf='%s' $t ) | |
case $size in | |
(0) | |
rm -f $t | |
exit 3 | |
;; | |
(*) | |
mv -i $t $4 | |
exit 0 | |
;; | |
esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment