{"thread":{"id":"5112","subject":"[RFC] Introduce git-xxdiff to invoke xxdiff for manual conflict resolution","startedAt":"2006-08-03T23:53:53Z","lastAt":"2006-08-05T03:26:34Z","messageCount":9,"participants":["Martin Langhoff","Junio C Hamano","Martin Langhoff (CatalystIT)","Jeff King","Alex Riesen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"24671","messageId":"11546492331601-git-send-email-martin@catalyst.net.nz","threadId":"5112","inReplyTo":null,"subject":"[RFC] Introduce git-xxdiff to invoke xxdiff for manual conflict resolution","fromName":"Martin Langhoff","fromEmail":"martin@catalyst.net.nz","sentAt":"2006-08-03T23:53:53Z","receivedAt":"2006-08-03T23:53:53Z","isPatch":false,"sender":{"key":"martin@laptop.org","avatar":null},"body":"This is a bit of a crude but really useful shortcut for conflict resolution.\nThe name is bad, but git-merge-* is a different 'namespace', and git-resolve is\nalso taken.\n\nAnd as different conflict resolvers take different options, it may make sense\nto have git-xxdiff, git-sdiff and git-winmerge at least initially.\n\nSigned-off-by: Martin Langhoff <martin@catalyst.net.nz>\n---\n Makefile      |    2 +-\n git-xxdiff.sh |   38 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 39 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 8349e3d..a6f6628 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -145,7 +145,7 @@ SCRIPT_SH = \\\n \tgit-applymbox.sh git-applypatch.sh git-am.sh \\\n \tgit-merge.sh git-merge-stupid.sh git-merge-octopus.sh \\\n \tgit-merge-resolve.sh git-merge-ours.sh \\\n-\tgit-lost-found.sh git-quiltimport.sh\n+\tgit-lost-found.sh git-quiltimport.sh git-xxdiff.sh\n \n SCRIPT_PERL = \\\n \tgit-archimport.perl git-cvsimport.perl git-relink.perl \\\ndiff --git a/git-xxdiff.sh b/git-xxdiff.sh\nnew file mode 100755\nindex 0000000..d562ab2\n--- /dev/null\n+++ b/git-xxdiff.sh\n@@ -0,0 +1,38 @@\n+#!/bin/sh\n+\n+USAGE='<path>'\n+SUBDIRECTORY_OK=No\n+. git-sh-setup\n+\n+FILE=$1\n+MERGE_HEAD=`git rev-parse MERGE_HEAD`\n+\n+# Sanity checks\n+if test ! -n \"$FILE\"\n+then\n+\techo Need a path\n+\texit 1\n+fi\n+\n+if test ! -n \"$MERGE_HEAD\"\n+then\n+\techo git-xxdiff is only useful during a merge\n+fi\n+\n+git cat-file blob HEAD:$FILE > $FILE~HEAD\n+if test $? -gt 0\n+then \n+\techo \"Error - maybe $FILE is not tracked by git?\"\n+\texit\n+fi\n+echo Written $FILE~HEAD\n+\n+git cat-file blob $MERGE_HEAD:$FILE > $FILE~MERGE_HEAD\n+if  test $? -gt 0\n+then \n+\techo \"Error - maybe $FILE is not tracked by git?\"\n+\texit\n+fi\n+echo Written $FILE~MERGE_HEAD\n+\n+xxdiff -wbB --show-merged-pane --merged-filename $FILE~merged $FILE~HEAD $FILE~MERGE_HEAD\n\\ No newline at end of file\n-- \n1.4.2.rc2.g1869bc-dirty\n"},{"id":"24673","messageId":"7v64h9pdx4.fsf@assigned-by-dhcp.cox.net","threadId":"5112","inReplyTo":"11546492331601-git-send-email-martin@catalyst.net.nz","subject":"Re: [RFC] Introduce git-xxdiff to invoke xxdiff for manual conflict resolution","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-04T00:01:11Z","receivedAt":"2006-08-04T00:01:11Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Langhoff <martin@catalyst.net.nz> writes:\n\n> diff --git a/git-xxdiff.sh b/git-xxdiff.sh\n> new file mode 100755\n> index 0000000..d562ab2\n> --- /dev/null\n> +++ b/git-xxdiff.sh\n> @@ -0,0 +1,38 @@\n> +#!/bin/sh\n> +\n> +USAGE='<path>'\n> +SUBDIRECTORY_OK=No\n> +. git-sh-setup\n> +\n> +FILE=$1\n> +MERGE_HEAD=`git rev-parse MERGE_HEAD`\n> +\n> +# Sanity checks\n\nWe can have unmerged index without MERGE_HEAD (for example,\nthink \"rebase --merge\" or \"am -3\"); drop check for that and\ninstead check for stage 2 (\"ours\") for the path.\n\n\tgit cat-file blob :2:$FILE\n\nCan xxdiff take more than one file pairs?\n\nIf so you might want to list unmerged paths (ls-files -u) and\niterate through it when no paths are given from the command\nline.  If not, you might want to take the first unmerged path\nwhen no paths are given from the command line.\n\n> +xxdiff -wbB --show-merged-pane --merged-filename $FILE~merged $FILE~HEAD $FILE~MERGE_HEAD\n> \\ No newline at end of file\n\n;-).\n"},{"id":"24674","messageId":"44D291EF.4020506@catalyst.net.nz","threadId":"5112","inReplyTo":"7v64h9pdx4.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC] Introduce git-xxdiff to invoke xxdiff for manual conflict resolution","fromName":"Martin Langhoff (CatalystIT)","fromEmail":"martin@catalyst.net.nz","sentAt":"2006-08-04T00:16:47Z","receivedAt":"2006-08-04T00:16:47Z","isPatch":false,"sender":{"key":"martin@laptop.org","avatar":null},"body":"Junio C Hamano wrote:\n\n>>diff --git a/git-xxdiff.sh b/git-xxdiff.sh\n>>new file mode 100755\n>>index 0000000..d562ab2\n>>--- /dev/null\n>>+++ b/git-xxdiff.sh\n>>@@ -0,0 +1,38 @@\n>>+#!/bin/sh\n>>+\n>>+USAGE='<path>'\n>>+SUBDIRECTORY_OK=No\n>>+. git-sh-setup\n>>+\n>>+FILE=$1\n>>+MERGE_HEAD=`git rev-parse MERGE_HEAD`\n>>+\n>>+# Sanity checks\n> \n> \n> We can have unmerged index without MERGE_HEAD (for example,\n> think \"rebase --merge\" or \"am -3\"); drop check for that and\n> instead check for stage 2 (\"ours\") for the path.\n> \n> \tgit cat-file blob :2:$FILE\n\n(didn't know the :$stage: trick, neat)\n\nI did think of using merge stages but I wasn't sure whether all the \nmerge strategies followed the same convention. I'll fix up and re-post it.\n\n> Can xxdiff take more than one file pairs?\n\nNot that I can see.\n\n>>+xxdiff -wbB --show-merged-pane --merged-filename $FILE~merged $FILE~HEAD $FILE~MERGE_HEAD\n>>\\ No newline at end of file\n> \n> ;-).\n\nOuch, yes, I forgot the newline. Grumble.\n\nI am also telling xxdiff to save the merged file as ~merged rather than \noverwriting the merge attempt that git has made. Better safe than sorry.\n\ncheers,\n\nm\n-- \n-----------------------------------------------------------------------\nMartin @ Catalyst .Net .NZ  Ltd, PO Box 11-053, Manners St,  Wellington\nWEB: http://catalyst.net.nz/           PHYS: Level 2, 150-154 Willis St\nOFFICE: +64(4)916-7224                              MOB: +64(21)364-017\n       Make things as simple as possible, but no simpler - Einstein\n-----------------------------------------------------------------------\n"},{"id":"24676","messageId":"11546518271379-git-send-email-martin@catalyst.net.nz","threadId":"5112","inReplyTo":"7v64h9pdx4.fsf@assigned-by-dhcp.cox.net","subject":"[RFC] Introduce git-xxdiff to invoke xxdiff for manual conflict resolution - take 2","fromName":"Martin Langhoff","fromEmail":"martin@catalyst.net.nz","sentAt":"2006-08-04T00:37:07Z","receivedAt":"2006-08-04T00:37:07Z","isPatch":false,"sender":{"key":"martin@laptop.org","avatar":null},"body":"This is a bit of a crude but really useful shortcut for conflict resolution.\nThe name is bad, but git-merge-* is a different 'namespace', and git-resolve is\nalso taken.\n\nAnd as different conflict resolvers take different options, it may make sense\nto have git-xxdiff, git-sdiff and git-winmerge at least initially.\n\nReposting with some fixes suggested by Junio.\n\nSigned-off-by: Martin Langhoff <martin@catalyst.net.nz>\n---\n\nHow about this one? ;-)\n---\n Makefile      |    2 +-\n git-xxdiff.sh |   33 +++++++++++++++++++++++++++++++++\n 2 files changed, 34 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 8349e3d..a6f6628 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -145,7 +145,7 @@ SCRIPT_SH = \\\n \tgit-applymbox.sh git-applypatch.sh git-am.sh \\\n \tgit-merge.sh git-merge-stupid.sh git-merge-octopus.sh \\\n \tgit-merge-resolve.sh git-merge-ours.sh \\\n-\tgit-lost-found.sh git-quiltimport.sh\n+\tgit-lost-found.sh git-quiltimport.sh git-xxdiff.sh\n \n SCRIPT_PERL = \\\n \tgit-archimport.perl git-cvsimport.perl git-relink.perl \\\ndiff --git a/git-xxdiff.sh b/git-xxdiff.sh\nnew file mode 100755\nindex 0000000..3dc9876\n--- /dev/null\n+++ b/git-xxdiff.sh\n@@ -0,0 +1,33 @@\n+#!/bin/sh\n+\n+USAGE='<path-with-conflict>'\n+SUBDIRECTORY_OK=No\n+. git-sh-setup\n+\n+FILE=$1\n+\n+# Sanity checks\n+if test ! -n \"$FILE\"\n+then\n+\techo Need a path\n+\texit 1\n+fi\n+\n+git cat-file blob :2:$FILE > $FILE~ours\n+if test $? -gt 0\n+then \n+\techo \"Error - $FILE is not tracked by git or does not have a conflict\"\n+\texit 1\n+fi\n+echo Written $FILE~ours\n+\n+git cat-file blob :3:$FILE > $FILE~branch\n+if  test $? -gt 0\n+then \n+\techo \"Error - $FILE is not tracked by git or does not have a conflict\"\n+\texit 1\n+fi\n+echo Written $FILE~branch\n+echo Resolved file will be saved as $FILE~merged\n+\n+xxdiff -wbB --show-merged-pane --merged-filename $FILE~merged $FILE~ours $FILE~branch\n-- \n1.4.2.rc2.g1869bc-dirty\n"},{"id":"24677","messageId":"44D296D8.4030200@catalyst.net.nz","threadId":"5112","inReplyTo":"7v64h9pdx4.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC] Introduce git-xxdiff to invoke xxdiff for manual conflict resolution","fromName":"Martin Langhoff (CatalystIT)","fromEmail":"martin@catalyst.net.nz","sentAt":"2006-08-04T00:37:44Z","receivedAt":"2006-08-04T00:37:44Z","isPatch":false,"sender":{"key":"martin@laptop.org","avatar":null},"body":"Junio C Hamano wrote:\n\n> We can have unmerged index without MERGE_HEAD (for example,\n> think \"rebase --merge\" or \"am -3\"); drop check for that and\n> instead check for stage 2 (\"ours\") for the path.\n\nReading Documentation/git-read-tree.txt it seems to mean that stage 1 is \nmerge base, 1 is ours and 2 is the branch being merged in.\n\nI am confused...\n\nQuote:\n> When performing a merge of another\n> branch into the current branch, we use the common ancestor tree\n> as <tree1>, the current branch head as <tree2>, and the other\n> branch head as <tree3>.\n\n\nm\n-- \n-----------------------------------------------------------------------\nMartin @ Catalyst .Net .NZ  Ltd, PO Box 11-053, Manners St,  Wellington\nWEB: http://catalyst.net.nz/           PHYS: Level 2, 150-154 Willis St\nOFFICE: +64(4)916-7224                              MOB: +64(21)364-017\n       Make things as simple as possible, but no simpler - Einstein\n-----------------------------------------------------------------------\n"},{"id":"24678","messageId":"20060804033144.GB24818@coredump.intra.peff.net","threadId":"5112","inReplyTo":"44D296D8.4030200@catalyst.net.nz","subject":"Re: [RFC] Introduce git-xxdiff to invoke xxdiff for manual conflict resolution","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2006-08-04T03:31:44Z","receivedAt":"2006-08-04T03:31:44Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Aug 04, 2006 at 12:37:44PM +1200, Martin Langhoff (CatalystIT) wrote:\n\n> >instead check for stage 2 (\"ours\") for the path.\n> Reading Documentation/git-read-tree.txt it seems to mean that stage 1 is \n> merge base, 1 is ours and 2 is the branch being merged in.\n> \n> I am confused...\n> \n> Quote:\n> >When performing a merge of another\n> >branch into the current branch, we use the common ancestor tree\n> >as <tree1>, the current branch head as <tree2>, and the other\n> >branch head as <tree3>.\n\nLook further down:\n   OK, this all sounds like a collection of totally nonsensical rules,\n   but it's actually exactly what you want in order to do a  fast\n   merge.  The different stages  represent the \"result tree\" (stage 0,\n   aka \"merged\"), the original tree (stage 1, aka \"orig\"), and the two\n   trees you are trying to merge (stage 2 and 3 respectively).\n\nHTH,\n-Peff\n"},{"id":"24681","messageId":"44D2C393.8090508@catalyst.net.nz","threadId":"5112","inReplyTo":"20060804033144.GB24818@coredump.intra.peff.net","subject":"Re: [RFC] Introduce git-xxdiff to invoke xxdiff for manual conflict resolution","fromName":"Martin Langhoff (CatalystIT)","fromEmail":"martin@catalyst.net.nz","sentAt":"2006-08-04T03:48:35Z","receivedAt":"2006-08-04T03:48:35Z","isPatch":false,"sender":{"key":"martin@laptop.org","avatar":null},"body":"Jeff King wrote:\n\n> On Fri, Aug 04, 2006 at 12:37:44PM +1200, Martin Langhoff (CatalystIT) wrote:\n> \n> \n>>>instead check for stage 2 (\"ours\") for the path.\n>>\n>>Reading Documentation/git-read-tree.txt it seems to mean that stage 1 is \n>>merge base, 1 is ours and 2 is the branch being merged in.\n>>\n>>I am confused...\n>>\n>>Quote:\n>>\n>>>When performing a merge of another\n>>>branch into the current branch, we use the common ancestor tree\n>>>as <tree1>, the current branch head as <tree2>, and the other\n>>>branch head as <tree3>.\n> \n> \n> Look further down:\n>    OK, this all sounds like a collection of totally nonsensical rules,\n>    but it's actually exactly what you want in order to do a  fast\n>    merge.  The different stages  represent the \"result tree\" (stage 0,\n>    aka \"merged\"), the original tree (stage 1, aka \"orig\"), and the two\n>    trees you are trying to merge (stage 2 and 3 respectively).\n\nGrr. I just re-read my own email, and I can't believe how stupid my \nquestion was. Still, git-xxdiff is doing the right thing, stage 2 is \n\"ours\" and stage 3 is \"branch we are merging in\".\n\ncheers,\n\n\nmartin\n-- \n-----------------------------------------------------------------------\nMartin @ Catalyst .Net .NZ  Ltd, PO Box 11-053, Manners St,  Wellington\nWEB: http://catalyst.net.nz/           PHYS: Level 2, 150-154 Willis St\nOFFICE: +64(4)916-7224                              MOB: +64(21)364-017\n       Make things as simple as possible, but no simpler - Einstein\n-----------------------------------------------------------------------\n"},{"id":"24692","messageId":"81b0412b0608040109q683bd628rd9238662e0fdfb0@mail.gmail.com","threadId":"5112","inReplyTo":"11546518271379-git-send-email-martin@catalyst.net.nz","subject":"Re: [RFC] Introduce git-xxdiff to invoke xxdiff for manual conflict resolution - take 2","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2006-08-04T08:09:36Z","receivedAt":"2006-08-04T08:09:36Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 8/4/06, Martin Langhoff <martin@catalyst.net.nz> wrote:\n> This is a bit of a crude but really useful shortcut for conflict resolution.\n> The name is bad, but git-merge-* is a different 'namespace', and git-resolve is\n> also taken.\n\ngit-xxmerge?\n"},{"id":"24791","messageId":"46a038f90608042026l732cef04u46df9b3429cd04d4@mail.gmail.com","threadId":"5112","inReplyTo":"81b0412b0608040109q683bd628rd9238662e0fdfb0@mail.gmail.com","subject":"Re: [RFC] Introduce git-xxdiff to invoke xxdiff for manual conflict resolution - take 2","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2006-08-05T03:26:34Z","receivedAt":"2006-08-05T03:26:34Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On 8/4/06, Alex Riesen <raa.lkml@gmail.com> wrote:\n> On 8/4/06, Martin Langhoff <martin@catalyst.net.nz> wrote:\n> > This is a bit of a crude but really useful shortcut for conflict resolution.\n> > The name is bad, but git-merge-* is a different 'namespace', and git-resolve is\n> > also taken.\n>\n> git-xxmerge?\n\nWell, the xx part is taken because it uses xxdiff, so I thought\nperhaps we can have trivial git wrappers for many popular mergers. Ie:\ngit-wiggle, git-sdiff.\n\nWe could have a single command with a 'strategy' parameter, say\n\n     git-mergehelper -s [xxdiff|sdiff|wiggle] path/to/file\n\nbut separate commands are easier for prototyping IMVHO.\n\ncheers,\n\n\nmartin\n"}]}