{"thread":{"id":"9479","subject":"[PATCH 1/2] mergetool: refactored kdiff3 -> KDIFF3","startedAt":"2007-08-10T23:56:00Z","lastAt":"2007-08-10T23:56:01Z","messageCount":2,"participants":["Steffen Prohaska"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"50448","messageId":"11867901612954-git-send-email-prohaska@zib.de","threadId":"9479","inReplyTo":null,"subject":"[PATCH 1/2] mergetool: refactored kdiff3 -> KDIFF3","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-08-10T23:56:00Z","receivedAt":"2007-08-10T23:56:00Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"Use shell variable KDIFF3 instead of kdiff3 to call\nkdiff3. This will be used in detection of the absolute\nabsolute path.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n git-mergetool.sh |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\n\nThis change is needed to be able to provide an absolute\npath to kdiff3, which will be looked up in the Windows\nRegistry. See the following patch.\n\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex e6bbb6b..90a69b3 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -13,6 +13,8 @@ SUBDIRECTORY_OK=Yes\n . git-sh-setup\n require_work_tree\n \n+KDIFF3=kdiff3\n+\n # Returns true if the mode reflects a symlink\n is_symlink () {\n     test \"$1\" = 120000\n@@ -191,10 +193,10 @@ merge_file () {\n     case \"$merge_tool\" in\n \tkdiff3)\n \t    if base_present ; then\n-\t\t(kdiff3 --auto --L1 \"$path (Base)\" -L2 \"$path (Local)\" --L3 \"$path (Remote)\" \\\n+\t\t(\"$KDIFF3\" --auto --L1 \"$path (Base)\" -L2 \"$path (Local)\" --L3 \"$path (Remote)\" \\\n \t\t    -o \"$path\" -- \"$BASE\" \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n \t    else\n-\t\t(kdiff3 --auto -L1 \"$path (Local)\" --L2 \"$path (Remote)\" \\\n+\t\t(\"$KDIFF3\" --auto -L1 \"$path (Local)\" --L2 \"$path (Remote)\" \\\n \t\t    -o \"$path\" -- \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n \t    fi\n \t    status=$?\n-- \n1.5.3.rc4.744.g68381\n"},{"id":"50449","messageId":"11867901621009-git-send-email-prohaska@zib.de","threadId":"9479","inReplyTo":"11867901612954-git-send-email-prohaska@zib.de","subject":"[PATCH] mergetool: added support for kdiff3 on windows","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-08-10T23:56:01Z","receivedAt":"2007-08-10T23:56:01Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"kdiff3's homepage is http://kdiff3.sourceforge.net/.\n\nkdiff3 is automatically added to the available\nmergetools if its path is found in the Windows\nRegistry. Be sure to set\n\n    git config core.autocrlf true\n\nkdiff3 seems to follow Windows crlf convention.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n git-mergetool.sh |   22 ++++++++++++++++++----\n 1 files changed, 18 insertions(+), 4 deletions(-)\n\n\nThis patch was developed against msysgit, and is add\nfunctionality specific to Windows. It should also apply\nagainst git.git's master and shouldn't do any harm\nto the handling of mergetools on platforms other than\nWindows\n\nIt was tested on a Windows with german localization. I'd\nbe interested if the lookup of kdiff3 works on other\nlocalizations, too.\n\nHandling mergetools that needs an absolute path is a bit\nhacky. merge_tool is mostly used as an alias but also as\nthe name of an executable. A level of indirection would\nbe nice for handling absolute paths.\n\nkdiff3 on Windows doesn't accept '--' on it's commandline.\nIs '--' really needed on other platforms? I replaced it by\nthe variable KDIFF3SEPARATOR.\n\n\tSteffen\n\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 90a69b3..9f64e7c 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -14,6 +14,7 @@ SUBDIRECTORY_OK=Yes\n require_work_tree\n \n KDIFF3=kdiff3\n+KDIFF3SEPARATOR=--\n \n # Returns true if the mode reflects a symlink\n is_symlink () {\n@@ -194,10 +195,10 @@ merge_file () {\n \tkdiff3)\n \t    if base_present ; then\n \t\t(\"$KDIFF3\" --auto --L1 \"$path (Base)\" -L2 \"$path (Local)\" --L3 \"$path (Remote)\" \\\n-\t\t    -o \"$path\" -- \"$BASE\" \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n+\t\t    -o \"$path\" $KDIFF3SEPERATOR \"$BASE\" \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n \t    else\n \t\t(\"$KDIFF3\" --auto -L1 \"$path (Local)\" --L2 \"$path (Remote)\" \\\n-\t\t    -o \"$path\" -- \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n+\t\t    -o \"$path\" $KDIFF3SEPERATOR \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n \t    fi\n \t    status=$?\n \t    remove_backup\n@@ -321,6 +322,11 @@ if test -z \"$merge_tool\" ; then\n             merge_tool_candidates=\"kdiff3 $merge_tool_candidates\"\n         fi\n     fi\n+    regentry=\"$(REG QUERY 'HKEY_LOCAL_MACHINE\\SOFTWARE\\KDiff3\\diff-ext' 2>/dev/null)\" && {\n+        KDIFF3=$(echo \"$regentry\" | grep diffcommand | cut -f 3)\n+        KDIFF3SEPARATOR=\n+        merge_tool_candidates=\"$merge_tool_candidates kdiff3\"\n+    } \n     if echo \"${VISUAL:-$EDITOR}\" | grep 'emacs' > /dev/null 2>&1; then\n         merge_tool_candidates=\"$merge_tool_candidates emerge\"\n     fi\n@@ -332,10 +338,12 @@ if test -z \"$merge_tool\" ; then\n     for i in $merge_tool_candidates; do\n         if test $i = emerge ; then\n             cmd=emacs\n+        elif test $i = kdiff3 ; then\n+            cmd=\"$KDIFF3\"\n         else\n             cmd=$i\n         fi\n-        if type $cmd > /dev/null 2>&1; then\n+        if type \"$cmd\" > /dev/null 2>&1; then\n             merge_tool=$i\n             break\n         fi\n@@ -347,7 +355,13 @@ if test -z \"$merge_tool\" ; then\n fi\n \n case \"$merge_tool\" in\n-    kdiff3|tkdiff|meld|xxdiff|vimdiff|gvimdiff|opendiff)\n+    kdiff3)\n+\tif ! type \"$KDIFF3\" > /dev/null 2>&1; then\n+\t    echo \"The merge tool $merge_tool is not available\"\n+\t    exit 1\n+\tfi\n+\t;;\n+    tkdiff|meld|xxdiff|vimdiff|gvimdiff|opendiff)\n \tif ! type \"$merge_tool\" > /dev/null 2>&1; then\n \t    echo \"The merge tool $merge_tool is not available\"\n \t    exit 1\n-- \n1.5.3.rc4.744.g68381\n"}]}