{"thread":{"id":"19942","subject":"Re: Choosing a mergetool according to file type","startedAt":"2009-06-26T11:04:54Z","lastAt":"2009-06-26T17:43:34Z","messageCount":8,"participants":["Gregory Jefferis","Johannes Sixt","Matthieu Moy","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"117013","messageId":"C66A69E6.205F2%jefferis@gmail.com","threadId":"19942","inReplyTo":"4A44A66B.10906@viscovery.net","subject":"Re: Choosing a mergetool according to file type","fromName":"Gregory Jefferis","fromEmail":"jefferis@gmail.com","sentAt":"2009-06-26T11:04:54Z","receivedAt":"2009-06-26T11:04:54Z","isPatch":false,"sender":{"key":"jefferis@gmail.com","avatar":"https://gravatar.com/avatar/8528f4e227ebc88380c203c816e263246064e31f6180681dc2c6dabfaff24d6b?d=mp&s=160"},"body":"Hi Johannes,\n\nOn 2009-06-26 11:43, \"Johannes Sixt\" <j.sixt@viscovery.net> wrote:\n\n> I don't think that you can choose the merge tool by setting attributes.\n\nOK, that was my impression, but I wanted to check.\n\n > The reason I write to you is: Can you tell me what 'wordgitmerge' and\n> 'wordgitdiff' are?\n> \n> I, too, have a number of Word files that I need to merge every now and then.\n\nAh!  Well they are nothing fancy, I'm afraid, just scripts that call Word\nitself, but that turns out to work pretty well.  For Mac (my platform) they\nhave to be in applescript.  For Windows I imagine they could be pretty much\nthe same as the scripts here:\n\nhttp://tortoisesvn.tigris.org/svn/tortoisesvn/trunk/contrib/diff-scripts/\n\ndiff-doc.js\nmerge-doc.js\n\nPerhaps tortoisegit already exposes this.  Those scripts include fallbacks\nfor openoffice so I suppose one could use that on linux.\n\nBest,\n\nGreg.\n"},{"id":"117015","messageId":"4A44B128.6040800@viscovery.net","threadId":"19942","inReplyTo":"C66A69E6.205F2%jefferis@gmail.com","subject":"Re: Choosing a mergetool according to file type","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-06-26T11:29:44Z","receivedAt":"2009-06-26T11:29:44Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Gregory Jefferis schrieb:\n> http://tortoisesvn.tigris.org/svn/tortoisesvn/trunk/contrib/diff-scripts/\n> \n> diff-doc.js\n> merge-doc.js\n> \n> Perhaps tortoisegit already exposes this.  Those scripts include fallbacks\n> for openoffice so I suppose one could use that on linux.\n\nThanks a lot for the pointer.\n\nThe interesting one is merge-doc.js. Unfortunately, it still only just\ncompares \"their\" and \"our\" versions, and the user must go through all\nmarked changes and reject everything that would undo \"our\" changes and\naccept all \"their\" changes. That's exactly what I already do. :-(\n\nThat said, the scripts are written *much* nicer than what I have written\nmyself.\n\n-- Hannes\n"},{"id":"117016","messageId":"vpqd48rw68k.fsf@bauges.imag.fr","threadId":"19942","inReplyTo":"C66A69E6.205F2%jefferis@gmail.com","subject":"Re: Choosing a mergetool according to file type","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2009-06-26T12:04:59Z","receivedAt":"2009-06-26T12:04:59Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Gregory Jefferis <jefferis@gmail.com> writes:\n\n> Hi Johannes,\n>\n> On 2009-06-26 11:43, \"Johannes Sixt\" <j.sixt@viscovery.net> wrote:\n>\n>> I don't think that you can choose the merge tool by setting attributes.\n>\n> OK, that was my impression, but I wanted to check.\n\nNever used it, but man gitattributes says\n\n   Performing a three-way merge\n       merge\n[...]\n              String\n                 3-way merge is performed using the specified custom merge driver. The built-in 3-way merge driver can be explicitly specified by asking\n                 for \"text\" driver; the built-in \"take the current branch\" driver can be requested with \"binary\".\n[...]\n       Defining a custom merge driver\n\nIs it not what you're looking for?\n\n-- \nMatthieu\n"},{"id":"117020","messageId":"C66A8B6B.20617%jefferis@gmail.com","threadId":"19942","inReplyTo":"vpqd48rw68k.fsf@bauges.imag.fr","subject":"Re: Choosing a mergetool according to file type","fromName":"Gregory Jefferis","fromEmail":"jefferis@gmail.com","sentAt":"2009-06-26T13:27:55Z","receivedAt":"2009-06-26T13:27:55Z","isPatch":false,"sender":{"key":"jefferis@gmail.com","avatar":"https://gravatar.com/avatar/8528f4e227ebc88380c203c816e263246064e31f6180681dc2c6dabfaff24d6b?d=mp&s=160"},"body":"Hi Matthieu,\n\nThanks for your reply.\n\nOn 2009-06-26 13:04, \"Matthieu Moy\" <Matthieu.Moy@imag.fr> wrote:\n\n> Never used it, but man gitattributes says\n> \n>    Performing a three-way merge\n>        merge\n> [...]\n>               String\n>                  3-way merge is performed using the specified custom merge\n> driver. The built-in 3-way merge driver can be explicitly specified by asking\n>                  for \"text\" driver; the built-in \"take the current branch\"\n> driver can be requested with \"binary\".\n> [...]\n>        Defining a custom merge driver\n> \n> Is it not what you're looking for?\n\nThis defines the merge driver but not the mergetool.  A mergetool is\npresumably an interactive tool that helps you clean up failed automatic\nmerges.  For my binary files the internal merge driver \"binary\" will be used\nwhich as your quote points our keeps the local file and signals a conflict\nif it is different from the remote file.  I cannot define a custom merge\ndriver for my binary word files because I don't have such a program (which\nwould have to carry out the merge in a non-interactive fashion).  As\nmergetool I use a script that calls Word and that of course has to be\ninteractive.\n\nBest,\n\nGreg.\n"},{"id":"117022","messageId":"vpq7hyzqf1i.fsf@bauges.imag.fr","threadId":"19942","inReplyTo":"C66A8B6B.20617%jefferis@gmail.com","subject":"Re: Choosing a mergetool according to file type","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2009-06-26T13:51:21Z","receivedAt":"2009-06-26T13:51:21Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Gregory Jefferis <jefferis@gmail.com> writes:\n\n> This defines the merge driver but not the mergetool.  A mergetool is\n> presumably an interactive tool that helps you clean up failed automatic\n> merges.\n\nThis is why I quoted the title of the section\n\n>>        Defining a custom merge driver\n\nJust tried it with \n\n[merge \"filfre\"]\n       name = feel-free merge driver\n       driver = gedit %O %A %B\n       recursive = binary\n\nIt did launch gedit interactively during the merge.\n\n-- \nMatthieu\n"},{"id":"117028","messageId":"7viqijszjw.fsf@alter.siamese.dyndns.org","threadId":"19942","inReplyTo":"vpq7hyzqf1i.fsf@bauges.imag.fr","subject":"Re: Choosing a mergetool according to file type","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-26T16:57:39Z","receivedAt":"2009-06-26T16:57:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@imag.fr> writes:\n\n> Gregory Jefferis <jefferis@gmail.com> writes:\n>\n>> This defines the merge driver but not the mergetool.  A mergetool is\n>> presumably an interactive tool that helps you clean up failed automatic\n>> merges.\n>\n> This is why I quoted the title of the section\n>\n>>>        Defining a custom merge driver\n>\n> Just tried it with \n>\n> [merge \"filfre\"]\n>        name = feel-free merge driver\n>        driver = gedit %O %A %B\n>        recursive = binary\n>\n> It did launch gedit interactively during the merge.\n\nYou are both correct.  Your example runs \"gedit\" with three files before\nmerge.  If Gregory's custom mergetool expects the failed half-merge result\nas its input, this is not the interface he is looking for.\n\nIt shouldn't be hard to teach mergetool/difftool wrapper to support the\nper-path tool selection by running \"git check-attr\".\n\nRight now it uses \"diff.tool\" and \"merge.tool\" configuration variables.\nIn addition, it can arrange to consult \"mergetool.$type.diff\" and\n\"mergetool.$type.merge\".  These new two variables will override the\nexisting ones that are now treated as type-agnostic default.\n\nIOW, something like this.\n\n(1) In .gitattributes, define files whose name end with js is of type\n    gjefferis in the mergetool namespace:\n\n\t*.js\tmergetool=gjefferis\n\n(2) In .git/config, define that gjefferis type is handled by diff-doc.js\n    and merge-doc.js\n\n    [mergetool \"gjefferis\"]\n\tdiff = diff-doc.js\n        merge = merge-doc.js\n\n(3) Enhance get_configured_merge_tool() in git-mergetool--lib.sh and\n    callchain that leads to it.\n\n    type=$(git checkattr mergetool -- $file)\n    if test -n \"$type\"\n    then\n    \tmergetool=$(git config mergetool.$type.merge)\n        difftool=$(git config mergetool.$type.diff)\n    else\n        mergetool=$(git config merge.tool)\n        difftool=$(git config diff.tool)\n    fi\n\nIt appears that right now the function does not know what file it is\ndealing with, so you may need to first restructure the callchain a bit,\nbut it shouldn't be too painful.\n"},{"id":"117030","messageId":"C66ABE00.20643%jefferis@gmail.com","threadId":"19942","inReplyTo":"vpq7hyzqf1i.fsf@bauges.imag.fr","subject":"Re: Choosing a mergetool according to file type","fromName":"Gregory Jefferis","fromEmail":"jefferis@gmail.com","sentAt":"2009-06-26T17:03:44Z","receivedAt":"2009-06-26T17:03:44Z","isPatch":false,"sender":{"key":"jefferis@gmail.com","avatar":"https://gravatar.com/avatar/8528f4e227ebc88380c203c816e263246064e31f6180681dc2c6dabfaff24d6b?d=mp&s=160"},"body":"Hi Matthieu,\n\nOn 2009-06-26 14:51, \"Matthieu Moy\" <Matthieu.Moy@imag.fr> wrote:\n\n> Gregory Jefferis <jefferis@gmail.com> writes:\n> \n>> This defines the merge driver but not the mergetool.  A mergetool is\n>> presumably an interactive tool that helps you clean up failed automatic\n>> merges.\n> \n> This is why I quoted the title of the section\n> \n>>>        Defining a custom merge driver\n> \n> Just tried it with\n> \n> [merge \"filfre\"]\n>        name = feel-free merge driver\n>        driver = gedit %O %A %B\n>        recursive = binary\n> \n> It did launch gedit interactively during the merge.\n\nHmm, I had of course looked at this but this thought that it wouldn't do\nwhat I want. For one, I thought this would _always_ call gedit even if the\nfile is unchanged in remote. Testing, however this doesn't seem to be the\ncase. So I think you're right that this method can be used satisfactorily\neven with an interactive merge and I have made a little script that seems to\ndo what I need.\n\nOn the other hand to me it does somewhat violate the separation between\nautomatic and interactive merging and one probably has to be quite careful\nabout what state the merge files are left in - presumably things that\nwhoever wrote the builtin \"binary\" merge thought about carefully.\n\nAll the best,\n\nGreg.\n"},{"id":"117033","messageId":"C66AC756.2064B%jefferis@gmail.com","threadId":"19942","inReplyTo":"7viqijszjw.fsf@alter.siamese.dyndns.org","subject":"Re: Choosing a mergetool according to file type","fromName":"Gregory Jefferis","fromEmail":"jefferis@gmail.com","sentAt":"2009-06-26T17:43:34Z","receivedAt":"2009-06-26T17:43:34Z","isPatch":false,"sender":{"key":"jefferis@gmail.com","avatar":"https://gravatar.com/avatar/8528f4e227ebc88380c203c816e263246064e31f6180681dc2c6dabfaff24d6b?d=mp&s=160"},"body":"On 2009-06-26 17:57, \"Junio C Hamano\" <gitster@pobox.com> wrote:\n\n> You are both correct.  Your example runs \"gedit\" with three files before\n> merge.  If Gregory's custom mergetool expects the failed half-merge result\n> as its input, this is not the interface he is looking for.\n\nI think that Matthieu is more correct this time in that I can do what I need\nwith the merge driver because I don't need the failed half-merge result.\nBut I prefer the 2 level arrangement of 1) automatic then 2) fixing merge\nconflicts manually since there will be other cases where this is required.\n\nThank you Junio for pointing out how to do add the necessary functionality -\na project for a rainy weekend I guess.\n\nBest,\n\nGreg.\n"}]}