{"thread":{"id":"39378","subject":"[PATCH v3] mergetools: add winmerge as a builtin tool","startedAt":"2015-05-20T04:20:35Z","lastAt":"2015-05-20T07:11:48Z","messageCount":2,"participants":["David Aguilar","Sebastian Schuberth"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"261631","messageId":"1432095635-96710-1-git-send-email-davvid@gmail.com","threadId":"39378","inReplyTo":null,"subject":"[PATCH v3] mergetools: add winmerge as a builtin tool","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2015-05-20T04:20:35Z","receivedAt":"2015-05-20T04:20:35Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Add a winmerge scriptlet with the commands described in [1] so\nthat users can use winmerge without needing to perform any\nadditional configuration.\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/268631\n\nHelped-by: Philip Oakley <philipoakley@iee.org>\nHelped-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nHelped-by: Sebastian Schuberth <sschuberth@gmail.com>\nHelped-by: SZEDER Gábor <szeder@ira.uka.de>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\nChanges since v2: We now use \"$PROGRAMFILES\" exclusively\nand let the shell concatenate the \" (x86)\" part when testing\nfilesystem paths.  The C:/... hard-coded fallbacks have been\nremoved since $PROGRAMFILES should exist in practice.\n\n mergetools/winmerge | 35 +++++++++++++++++++++++++++++++++++\n 1 file changed, 35 insertions(+)\n create mode 100644 mergetools/winmerge\n\ndiff --git a/mergetools/winmerge b/mergetools/winmerge\nnew file mode 100644\nindex 0000000..435623c\n--- /dev/null\n+++ b/mergetools/winmerge\n@@ -0,0 +1,35 @@\n+diff_cmd () {\n+\t\"$merge_tool_path\" -u -e \"$LOCAL\" \"$REMOTE\"\n+\treturn 0\n+}\n+\n+merge_cmd () {\n+\t# mergetool.winmerge.trustExitCode is implicitly false.\n+\t# touch $BACKUP so that we can check_unchanged.\n+\ttouch \"$BACKUP\"\n+\t\"$merge_tool_path\" -u -e -dl Local -dr Remote \\\n+\t\t\"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n+\tcheck_unchanged\n+}\n+\n+translate_merge_tool_path() {\n+\t# Use WinMergeU.exe if it exists in $PATH\n+\tif type WinMergeU.exe >/dev/null 2>&1\n+\tthen\n+\t\techo WinMergeU.exe\n+\t\treturn\n+\tfi\n+\n+\t# Look for WinMergeU.exe in the typical locations\n+\twinmerge_exe=\"WinMerge/WinMergeU.exe\"\n+\n+\tif test -n \"$PROGRAMFILES\" && test -x \"$PROGRAMFILES (x86)/$winmerge_exe\"\n+\tthen\n+\t\tprintf '%s' \"$PROGRAMFILES (x86)/$winmerge_exe\"\n+\telif test -n \"$PROGRAMFILES\" && test -x \"$PROGRAMFILES/$winmerge_exe\"\n+\tthen\n+\t\tprintf '%s' \"$PROGRAMFILES/$winmerge_exe\"\n+\telse\n+\t\techo WinMergeU.exe\n+\tfi\n+}\n-- \n2.4.1.218.g416b006\n"},{"id":"261635","messageId":"CAHGBnuOwf2cBMZf1A6HuSoVTPxCem7fH3TOCHnYg3tW-QkoOEg@mail.gmail.com","threadId":"39378","inReplyTo":"1432095635-96710-1-git-send-email-davvid@gmail.com","subject":"Re: [PATCH v3] mergetools: add winmerge as a builtin tool","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2015-05-20T07:11:48Z","receivedAt":"2015-05-20T07:11:48Z","isPatch":true,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On Wed, May 20, 2015 at 6:20 AM, David Aguilar <davvid@gmail.com> wrote:\n\n> +translate_merge_tool_path() {\n> +       # Use WinMergeU.exe if it exists in $PATH\n> +       if type WinMergeU.exe >/dev/null 2>&1\n\nMaybe \"type -p\" here?\n\n> +       # Look for WinMergeU.exe in the typical locations\n> +       winmerge_exe=\"WinMerge/WinMergeU.exe\"\n> +\n> +       if test -n \"$PROGRAMFILES\" && test -x \"$PROGRAMFILES (x86)/$winmerge_exe\"\n> +       then\n> +               printf '%s' \"$PROGRAMFILES (x86)/$winmerge_exe\"\n> +       elif test -n \"$PROGRAMFILES\" && test -x \"$PROGRAMFILES/$winmerge_exe\"\n> +       then\n> +               printf '%s' \"$PROGRAMFILES/$winmerge_exe\"\n> +       else\n> +               echo WinMergeU.exe\n> +       fi\n> +}\n\nThis does not solve the problem reported by Dscho that some versions\nof Cygwin / MSYS 1 / MSYS 2 might export \"$ProgramFiles\" instead of\n\"$PROGRAMFILES\" (or similar for related variables).\n\nAlso there is a bit too much string duplication for my taste. And why\nuse \"echo\" in some places and \"printf\" in others?\n\nI still like a loop-based solution best:\n\nIFS=$'\\n'\nfor directory in $(env | grep -Ei '^PROGRAM(FILES(\\(X86\\))?|W6432)=' |\ncut -d '=' -f 2- | sort -u)\ndo\n    test -n \"$directory\" &&\n    test -x \"$directory/$winmerge_exe\" &&\n    echo \"$directory/$winmerge_exe\" &&\n    break\ndone\n\n-- \nSebastian Schuberth\n"}]}