{"thread":{"id":"1414","subject":"[PATCH] interactive merge in cg-Xmergefile for cogito-0.12.1","startedAt":"2005-08-04T19:32:42Z","lastAt":"2005-08-04T19:32:42Z","messageCount":1,"participants":["James Ketrenos"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"6802","messageId":"42F26D5A.7010602@linux.intel.com","threadId":"1414","inReplyTo":null,"subject":"[PATCH] interactive merge in cg-Xmergefile for cogito-0.12.1","fromName":"James Ketrenos","fromEmail":"jketreno@linux.intel.com","sentAt":"2005-08-04T19:32:42Z","receivedAt":"2005-08-04T19:32:42Z","isPatch":true,"sender":{"key":"jketreno@linux.intel.com","avatar":"https://gravatar.com/avatar/f4a487ad53c70943ed10ba220390cc7a004e4ba617c962bc4b7afcbd2bc08cc7?d=mp&s=160"},"body":"I use the attached patch here and its helped me quite a bit.  Thought\nI'd send it out for others to use as well.  Prior to 0.12 I could do\nthis in my own scripts after a cg-merge exited with conflicts.  Resently\nit seems 'git-ls-files --unmerged' will no longer list any files that\nhad conflicts during the merge.\n\nSo, this patch modifies cg-Xmergefile to interactively prompt you with\nwhat to do in the event of a merge conflict.  It is set up to work\nreasonably well with kdiff3 as is.\n\nIf it or a variant gets sucked into cogito -- great.  If there is\nalready a way to kick off a merge conflict resolution program while\ncg-merge is running, please let me know.\n\nThanks,\nJames\n\n\n\n cg-Xmergefile |   48 ++++++++++++++++++++++++++++++++++++++++++++++--\n 1 files changed, 46 insertions(+), 2 deletions(-)\n\n\ndiff -Nup a/cg-Xmergefile b/cg-Xmergefile\n--- a/cg-Xmergefile\t2005-08-04 14:20:38.000000000 -0500\n+++ b/cg-Xmergefile\t2005-08-04 15:20:01.000000000 -0500\n@@ -35,6 +35,49 @@ warning () {\n }\n \n \n+interactive_threeway() {\n+\t[ -z \"$MERGE\" ] && MERGE=\"kdiff3 -o\"\n+\tdir=$(dirname $4)\n+\t[ ! -d $dir ] && mkdir -p $dir\n+\tcmd=\"$MERGE \\\"$4\\\" \\\"$4.base\\\" \\\"$4.parent\\\" \\\"$4.child\\\"\"\n+\twhile true; do\n+\t\techo \"Do you wish to:\"\n+\t\techo -e \"1. Invoke MERGE via:\\n\"\\\n+\"$MERGE \\\"$4\\\" \\\"$4.base\\\" \\\"$4.parent\\\" \\\"$4.child\\\"\"\n+\t\techo \"2. restore from base\"\n+\t\techo \"3. restore from parent\"\n+\t\techo \"4. restore from child\"\n+\t\techo \"5. commit changes and return\"\n+\t\techo \"6. view file on disk\"\n+\t\techo \"0. abort\"\n+\t\tread -p \"[1-6,0] : \" reply <&1\n+\t\tcase $reply in\n+\t\t1)\tgit-cat-file blob $1 > $4.base\n+\t\t\tgit-cat-file blob $2 > $4.parent\n+\t\t\tgit-cat-file blob $3 > $4.child\n+\t\t\t$MERGE \"$4\" \"$4.base\" \"$4.parent\" \"$4.child\"\n+\t\t\t;;\n+\t\t2)\tgit-cat-file blob \"$1\" > \"$4\"\n+\t\t\techo \"Restored $4 from base\"\n+\t\t\t;;\n+\t\t3)\tgit-cat-file blob \"$2\" > \"$4\"\n+\t\t\techo \"Restored $4 from parent\"\n+\t\t\t;;\n+\t\t4)\tgit-cat-file blob \"$3\" > \"$4\"\n+\t\t\techo \"Restored $4 from child\"\n+\t\t\t;;\n+\t\t5)\tgit-update-cache -- $4 || return 1\n+\t\t\treturn 0\n+\t\t\t;;\n+\t\t6)\t[ ! -e \"$4\" ] && git-checkout-cache -q -f -u -- \"$4\"\n+\t\t\tless \"$4\"\n+\t\t\t;;\n+\t\t0)\treturn 1\n+\t\t\t;;\n+\t\tesac\n+\tdone\n+}\n+\n case \"${1:-.}${2:-.}${3:-.}\" in\n #\n # Deleted in both or deleted in one and unchanged in the other\n@@ -95,8 +138,7 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \tif [ $ret -ne 0 ]; then\n \t\t# The user already gets the warning from merge itself and\n \t\t# from merge-cache too. This is too much.\n-\t\t#error \"Auto-merge failed\"\n-\t\texit 1\n+\t\tinteractive_threeway $1 $2 $3 $4 || exit 1\n \tfi\n \texec git-update-cache -- \"$4\"\n \t;;\n@@ -106,3 +148,5 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \t;;\n esac\n exit 1\n+\n+\n"}]}