git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] interactive merge in cg-Xmergefile for cogito-0.12.1
@ 2005-08-04 19:32 James Ketrenos
  0 siblings, 0 replies; only message in thread
From: James Ketrenos @ 2005-08-04 19:32 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 680 bytes --]

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


[-- Attachment #2: cg-Xmergefile.diffstat --]
[-- Type: text/plain, Size: 122 bytes --]

 cg-Xmergefile |   48 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 46 insertions(+), 2 deletions(-)

[-- Attachment #3: cg-Xmergefile.patch --]
[-- Type: text/x-patch, Size: 1811 bytes --]

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
+
+

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-08-04 19:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-04 19:32 [PATCH] interactive merge in cg-Xmergefile for cogito-0.12.1 James Ketrenos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).