I use the attached patch here and its helped me quite a bit. Thought
I'd send it out for others to use as well. Prior to 0.12 I could do
this in my own scripts after a cg-merge exited with conflicts. Resently
it seems 'git-ls-files --unmerged' will no longer list any files that
had conflicts during the merge.
So, this patch modifies cg-Xmergefile to interactively prompt you with
what to do in the event of a merge conflict. It is set up to work
reasonably well with kdiff3 as is.
If it or a variant gets sucked into cogito -- great. If there is
already a way to kick off a merge conflict resolution program while
cg-merge is running, please let me know.
Thanks,
James
cg-Xmergefile | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 46 insertions(+), 2 deletions(-)
diff -Nup a/cg-Xmergefile b/cg-Xmergefile
--- a/cg-Xmergefile 2005-08-04 14:20:38.000000000 -0500
+++ b/cg-Xmergefile 2005-08-04 15:20:01.000000000 -0500
@@ -35,6 +35,49 @@ warning () {
}
+interactive_threeway() {
+ [ -z "$MERGE" ] && MERGE="kdiff3 -o"
+ dir=$(dirname $4)
+ [ ! -d $dir ] && mkdir -p $dir
+ cmd="$MERGE \"$4\" \"$4.base\" \"$4.parent\" \"$4.child\""
+ while true; do
+ echo "Do you wish to:"
+ echo -e "1. Invoke MERGE via:\n"\
+"$MERGE \"$4\" \"$4.base\" \"$4.parent\" \"$4.child\""
+ echo "2. restore from base"
+ echo "3. restore from parent"
+ echo "4. restore from child"
+ echo "5. commit changes and return"
+ echo "6. view file on disk"
+ echo "0. abort"
+ read -p "[1-6,0] : " reply <&1
+ case $reply in
+ 1) git-cat-file blob $1 > $4.base
+ git-cat-file blob $2 > $4.parent
+ git-cat-file blob $3 > $4.child
+ $MERGE "$4" "$4.base" "$4.parent" "$4.child"
+ ;;
+ 2) git-cat-file blob "$1" > "$4"
+ echo "Restored $4 from base"
+ ;;
+ 3) git-cat-file blob "$2" > "$4"
+ echo "Restored $4 from parent"
+ ;;
+ 4) git-cat-file blob "$3" > "$4"
+ echo "Restored $4 from child"
+ ;;
+ 5) git-update-cache -- $4 || return 1
+ return 0
+ ;;
+ 6) [ ! -e "$4" ] && git-checkout-cache -q -f -u -- "$4"
+ less "$4"
+ ;;
+ 0) return 1
+ ;;
+ esac
+ done
+}
+
case "${1:-.}${2:-.}${3:-.}" in
#
# Deleted in both or deleted in one and unchanged in the other
@@ -95,8 +138,7 @@ case "${1:-.}${2:-.}${3:-.}" in
if [ $ret -ne 0 ]; then
# The user already gets the warning from merge itself and
# from merge-cache too. This is too much.
- #error "Auto-merge failed"
- exit 1
+ interactive_threeway $1 $2 $3 $4 || exit 1
fi
exec git-update-cache -- "$4"
;;
@@ -106,3 +148,5 @@ case "${1:-.}${2:-.}${3:-.}" in
;;
esac
exit 1
+
+