All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Ketrenos <jketreno@linux.intel.com>
To: git@vger.kernel.org
Subject: [PATCH] interactive merge in cg-Xmergefile for cogito-0.12.1
Date: Thu, 04 Aug 2005 14:32:42 -0500	[thread overview]
Message-ID: <42F26D5A.7010602@linux.intel.com> (raw)

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

                 reply	other threads:[~2005-08-04 19:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42F26D5A.7010602@linux.intel.com \
    --to=jketreno@linux.intel.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.