{"thread":{"id":"10345","subject":"[PATCH 0/2 v3] mergetool","startedAt":"2007-10-17T17:16:10Z","lastAt":"2007-10-18T10:25:34Z","messageCount":10,"participants":["Steffen Prohaska","Shawn O. Pearce"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"56262","messageId":"11926413722362-git-send-email-prohaska@zib.de","threadId":"10345","inReplyTo":null,"subject":"[PATCH 0/2 v3] mergetool","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-10-17T17:16:10Z","receivedAt":"2007-10-17T17:16:10Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"So here they are again.\n\n    Steffen\n"},{"id":"56265","messageId":"11926413723666-git-send-email-prohaska@zib.de","threadId":"10345","inReplyTo":"11926413722362-git-send-email-prohaska@zib.de","subject":"[PATCH 1/2 v3] mergetool: use path to mergetool in config var mergetool.<tool>.path","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-10-17T17:16:11Z","receivedAt":"2007-10-17T17:16:11Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"This commit adds a mechanism to provide absolute paths to the\nexternal programs called by 'git mergetool'. A path can be\nspecified in the configuation variable mergetool.<tool>.path.\nThe configuration variable is similar to how we name branches\nand remotes. It is extensible if we need to specify more details\nabout a tool.\n\nThe mechanism is especially useful on Windows, where external\nprograms are unlikely to be in PATH.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n Documentation/git-mergetool.txt |    6 ++\n git-mergetool.sh                |   97 +++++++++++++++++++++-----------------\n 2 files changed, 60 insertions(+), 43 deletions(-)\n\ndiff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt\nindex 6c32c6d..78b2f43 100644\n--- a/Documentation/git-mergetool.txt\n+++ b/Documentation/git-mergetool.txt\n@@ -31,6 +31,12 @@ If a merge resolution program is not specified, 'git mergetool'\n will use the configuration variable merge.tool.  If the\n configuration variable merge.tool is not set, 'git mergetool'\n will pick a suitable default.\n++\n+You can explicitly provide a full path to the tool by setting the\n+configuration variable mergetool.<tool>.path. For example, you\n+can configure the absolute path to kdiff3 by setting\n+mergetool.kdiff3.path. Otherwise, 'git mergetool' assumes the tool\n+is available in PATH.\n \n Author\n ------\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 9f4f313..1e4583f 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -192,10 +192,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(\"$merge_tool_path\" --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(\"$merge_tool_path\" --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@@ -203,35 +203,35 @@ merge_file () {\n \t    ;;\n \ttkdiff)\n \t    if base_present ; then\n-\t\ttkdiff -a \"$BASE\" -o \"$path\" -- \"$LOCAL\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -a \"$BASE\" -o \"$path\" -- \"$LOCAL\" \"$REMOTE\"\n \t    else\n-\t\ttkdiff -o \"$path\" -- \"$LOCAL\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -o \"$path\" -- \"$LOCAL\" \"$REMOTE\"\n \t    fi\n \t    status=$?\n \t    save_backup\n \t    ;;\n \tmeld|vimdiff)\n \t    touch \"$BACKUP\"\n-\t    $merge_tool -- \"$LOCAL\" \"$path\" \"$REMOTE\"\n+\t    \"$merge_tool_path\" -- \"$LOCAL\" \"$path\" \"$REMOTE\"\n \t    check_unchanged\n \t    save_backup\n \t    ;;\n \tgvimdiff)\n \t\ttouch \"$BACKUP\"\n-\t\tgvimdiff -f -- \"$LOCAL\" \"$path\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -f -- \"$LOCAL\" \"$path\" \"$REMOTE\"\n \t\tcheck_unchanged\n \t\tsave_backup\n \t\t;;\n \txxdiff)\n \t    touch \"$BACKUP\"\n \t    if base_present ; then\n-\t\txxdiff -X --show-merged-pane \\\n+\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n \t\t    -R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n \t\t    -R 'Accel.Search: \"Ctrl+F\"' \\\n \t\t    -R 'Accel.SearchForward: \"Ctrl-G\"' \\\n \t\t    --merged-file \"$path\" -- \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \t    else\n-\t\txxdiff -X --show-merged-pane \\\n+\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n \t\t    -R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n \t\t    -R 'Accel.Search: \"Ctrl+F\"' \\\n \t\t    -R 'Accel.SearchForward: \"Ctrl-G\"' \\\n@@ -243,18 +243,18 @@ merge_file () {\n \topendiff)\n \t    touch \"$BACKUP\"\n \t    if base_present; then\n-\t\topendiff \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$path\" | cat\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$path\" | cat\n \t    else\n-\t\topendiff \"$LOCAL\" \"$REMOTE\" -merge \"$path\" | cat\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" -merge \"$path\" | cat\n \t    fi\n \t    check_unchanged\n \t    save_backup\n \t    ;;\n \temerge)\n \t    if base_present ; then\n-\t\temacs -f emerge-files-with-ancestor-command \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$(basename \"$path\")\"\n+\t\t\"$merge_tool_path\" -f emerge-files-with-ancestor-command \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$(basename \"$path\")\"\n \t    else\n-\t\temacs -f emerge-files-command \"$LOCAL\" \"$REMOTE\" \"$(basename \"$path\")\"\n+\t\t\"$merge_tool_path\" -f emerge-files-command \"$LOCAL\" \"$REMOTE\" \"$(basename \"$path\")\"\n \t    fi\n \t    status=$?\n \t    save_backup\n@@ -297,17 +297,38 @@ do\n     shift\n done\n \n+valid_tool() {\n+\tcase \"$1\" in\n+\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff)\n+\t\t\t;; # happy\n+\t\t*)\n+\t\t\treturn 1\n+\t\t\t;;\n+\tesac\n+}\n+\n+init_merge_tool_path() {\n+\tmerge_tool_path=`git config mergetool.$1.path`\n+\tif test -z \"$merge_tool_path\" ; then\n+\t\tcase \"$merge_tool\" in\n+\t\t\temerge)\n+\t\t\t\tmerge_tool_path=emacs\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmerge_tool_path=$merge_tool\n+\t\t\t\t;;\n+\t\tesac\n+\tfi\n+}\n+\n+\n if test -z \"$merge_tool\"; then\n     merge_tool=`git config merge.tool`\n-    case \"$merge_tool\" in\n-\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | \"\")\n-\t    ;; # happy\n-\t*)\n+    test -n \"$merge_tool\" || valid_tool \"$merge_tool\" || {\n \t    echo >&2 \"git config option merge.tool set to unknown tool: $merge_tool\"\n \t    echo >&2 \"Resetting to default...\"\n \t    unset merge_tool\n-\t    ;;\n-    esac\n+    }\n fi\n \n if test -z \"$merge_tool\" ; then\n@@ -329,40 +350,30 @@ if test -z \"$merge_tool\" ; then\n     merge_tool_candidates=\"$merge_tool_candidates opendiff emerge vimdiff\"\n     echo \"merge tool candidates: $merge_tool_candidates\"\n     for i in $merge_tool_candidates; do\n-        if test $i = emerge ; then\n-            cmd=emacs\n-        else\n-            cmd=$i\n-        fi\n-        if type $cmd > /dev/null 2>&1; then\n+        init_merge_tool_path $i\n+        if type \"$merge_tool_path\" > /dev/null 2>&1; then\n             merge_tool=$i\n             break\n         fi\n     done\n     if test -z \"$merge_tool\" ; then\n-\techo \"No available merge resolution programs available.\"\n+\techo \"No known merge resolution program available.\"\n \texit 1\n     fi\n+else\n+    valid_tool \"$merge_tool\" || {\n+        echo >&2 \"Unknown merge_tool $merge_tool\"\n+        exit 1\n+    }\n+\n+    init_merge_tool_path \"$merge_tool\"\n+\n+    if ! type \"$merge_tool_path\" > /dev/null 2>&1; then\n+        echo \"The merge tool $merge_tool is not available as '$merge_tool_path'\"\n+        exit 1\n+    fi\n fi\n \n-case \"$merge_tool\" in\n-    kdiff3|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-\tfi\n-\t;;\n-    emerge)\n-\tif ! type \"emacs\" > /dev/null 2>&1; then\n-\t    echo \"Emacs is not available\"\n-\t    exit 1\n-\tfi\n-\t;;\n-    *)\n-\techo \"Unknown merge tool: $merge_tool\"\n-\texit 1\n-\t;;\n-esac\n \n if test $# -eq 0 ; then\n \tfiles=`git ls-files -u | sed -e 's/^[^\t]*\t//' | sort -u`\n-- \n1.5.3.4.222.g2830\n"},{"id":"56264","messageId":"11926413721755-git-send-email-prohaska@zib.de","threadId":"10345","inReplyTo":"11926413723666-git-send-email-prohaska@zib.de","subject":"[PATCH 2/2 v3] mergetool: add support for ECMerge","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-10-17T17:16:12Z","receivedAt":"2007-10-17T17:16:12Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"Add support to mergetool for ECMerge available from\nhttp://www.elliecomputing.com/Products/merge_overview.asp\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n Documentation/git-mergetool.txt |    2 +-\n git-mergetool.sh                |   12 +++++++++++-\n 2 files changed, 12 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt\nindex 78b2f43..a26c260 100644\n--- a/Documentation/git-mergetool.txt\n+++ b/Documentation/git-mergetool.txt\n@@ -25,7 +25,7 @@ OPTIONS\n -t or --tool=<tool>::\n \tUse the merge resolution program specified by <tool>.\n \tValid merge tools are:\n-\tkdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, and opendiff\n+\tkdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff\n +\n If a merge resolution program is not specified, 'git mergetool'\n will use the configuration variable merge.tool.  If the\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 1e4583f..fdf4912 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -250,6 +250,16 @@ merge_file () {\n \t    check_unchanged\n \t    save_backup\n \t    ;;\n+\tecmerge)\n+\t    touch \"$BACKUP\"\n+\t    if base_present; then\n+\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" --mode=merge3 --to=\"$path\"\n+\t    else\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" --mode=merge2 --to=\"$path\"\n+\t    fi\n+\t    check_unchanged\n+\t    save_backup\n+\t    ;;\n \temerge)\n \t    if base_present ; then\n \t\t\"$merge_tool_path\" -f emerge-files-with-ancestor-command \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$(basename \"$path\")\"\n@@ -299,7 +309,7 @@ done\n \n valid_tool() {\n \tcase \"$1\" in\n-\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff)\n+\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)\n \t\t\t;; # happy\n \t\t*)\n \t\t\treturn 1\n-- \n1.5.3.4.222.g2830\n"},{"id":"56263","messageId":"F655F55F-04CC-465A-866F-8F5EF9158BD2@zib.de","threadId":"10345","inReplyTo":"11926413722362-git-send-email-prohaska@zib.de","subject":"Re: [PATCH 0/2 v3] mergetool","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-10-17T17:20:53Z","receivedAt":"2007-10-17T17:20:53Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Oct 17, 2007, at 7:16 PM, Steffen Prohaska wrote:\n\n> So here they are again.\n\n[ half of the message is missing. First time I used compose ;) ]\n\nI haven't found these two patches in Shawn's nor Lars' repo.\nI believe they would be pretty useful on Windows. They apply\nto spearce/master.\n\n\tSteffen\n"},{"id":"56347","messageId":"20071018052724.GA27813@spearce.org","threadId":"10345","inReplyTo":"11926413723666-git-send-email-prohaska@zib.de","subject":"Re: [PATCH 1/2 v3] mergetool: use path to mergetool in config var mergetool.<tool>.path","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-10-18T05:27:24Z","receivedAt":"2007-10-18T05:27:24Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Steffen Prohaska <prohaska@zib.de> wrote:\n> This commit adds a mechanism to provide absolute paths to the\n> external programs called by 'git mergetool'.  ...\n...\n> @@ -297,17 +297,38 @@ do\n>      shift\n>  done\n>  \n> +valid_tool() {\n> +\tcase \"$1\" in\n> +\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff)\n> +\t\t\t;; # happy\n> +\t\t*)\n> +\t\t\treturn 1\n> +\t\t\t;;\n> +\tesac\n> +}\n...\n> +    test -n \"$merge_tool\" || valid_tool \"$merge_tool\" || {\n\nWouldn't an empty $merge_tool string be caught above in the\nvalid_tool function where it falls through and returns 1?\nSo isn't test -n here redundant?\n\n-- \nShawn.\n"},{"id":"56369","messageId":"923DDB10-C9E9-4797-9FC1-D31DEEBE75B7@zib.de","threadId":"10345","inReplyTo":"20071018052724.GA27813@spearce.org","subject":"Re: [PATCH 1/2 v3] mergetool: use path to mergetool in config var mergetool.<tool>.path","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-10-18T07:52:12Z","receivedAt":"2007-10-18T07:52:12Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Oct 18, 2007, at 7:27 AM, Shawn O. Pearce wrote:\n\n> Steffen Prohaska <prohaska@zib.de> wrote:\n>> This commit adds a mechanism to provide absolute paths to the\n>> external programs called by 'git mergetool'.  ...\n> ...\n>> @@ -297,17 +297,38 @@ do\n>>      shift\n>>  done\n>>\n>> +valid_tool() {\n>> +\tcase \"$1\" in\n>> +\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff |  \n>> gvimdiff)\n>> +\t\t\t;; # happy\n>> +\t\t*)\n>> +\t\t\treturn 1\n>> +\t\t\t;;\n>> +\tesac\n>> +}\n> ...\n>> +    test -n \"$merge_tool\" || valid_tool \"$merge_tool\" || {\n>\n> Wouldn't an empty $merge_tool string be caught above in the\n> valid_tool function where it falls through and returns 1?\n> So isn't test -n here redundant?\n\nSharp eyes, thanks.\n\n\nCorrect is\n\ntest -z \"$merge_tool\" || valid_tool \"$merge_tool\" || {\n\nNo merge tool or a valid merge tool is allowed at this place.\nIf the tool's already empty there's no need to tell the user\nthat it will be reset to empty.\n\nI'll send a v4 version.\n\n\tSteffen\n"},{"id":"56370","messageId":"11926939882246-git-send-email-prohaska@zib.de","threadId":"10345","inReplyTo":"923DDB10-C9E9-4797-9FC1-D31DEEBE75B7@zib.de","subject":"[PATCH 1/2 v4] mergetool: use path to mergetool in config var mergetool.<tool>.path","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-10-18T07:53:08Z","receivedAt":"2007-10-18T07:53:08Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"This commit adds a mechanism to provide absolute paths to the\nexternal programs called by 'git mergetool'. A path can be\nspecified in the configuation variable mergetool.<tool>.path.\nThe configuration variable is similar to how we name branches\nand remotes. It is extensible if we need to specify more details\nabout a tool.\n\nThe mechanism is especially useful on Windows, where external\nprograms are unlikely to be in PATH.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n Documentation/git-mergetool.txt |    6 ++\n git-mergetool.sh                |   97 +++++++++++++++++++++-----------------\n 2 files changed, 60 insertions(+), 43 deletions(-)\n\ndiff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt\nindex 6c32c6d..78b2f43 100644\n--- a/Documentation/git-mergetool.txt\n+++ b/Documentation/git-mergetool.txt\n@@ -31,6 +31,12 @@ If a merge resolution program is not specified, 'git mergetool'\n will use the configuration variable merge.tool.  If the\n configuration variable merge.tool is not set, 'git mergetool'\n will pick a suitable default.\n++\n+You can explicitly provide a full path to the tool by setting the\n+configuration variable mergetool.<tool>.path. For example, you\n+can configure the absolute path to kdiff3 by setting\n+mergetool.kdiff3.path. Otherwise, 'git mergetool' assumes the tool\n+is available in PATH.\n \n Author\n ------\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 9f4f313..987aeda 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -192,10 +192,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(\"$merge_tool_path\" --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(\"$merge_tool_path\" --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@@ -203,35 +203,35 @@ merge_file () {\n \t    ;;\n \ttkdiff)\n \t    if base_present ; then\n-\t\ttkdiff -a \"$BASE\" -o \"$path\" -- \"$LOCAL\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -a \"$BASE\" -o \"$path\" -- \"$LOCAL\" \"$REMOTE\"\n \t    else\n-\t\ttkdiff -o \"$path\" -- \"$LOCAL\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -o \"$path\" -- \"$LOCAL\" \"$REMOTE\"\n \t    fi\n \t    status=$?\n \t    save_backup\n \t    ;;\n \tmeld|vimdiff)\n \t    touch \"$BACKUP\"\n-\t    $merge_tool -- \"$LOCAL\" \"$path\" \"$REMOTE\"\n+\t    \"$merge_tool_path\" -- \"$LOCAL\" \"$path\" \"$REMOTE\"\n \t    check_unchanged\n \t    save_backup\n \t    ;;\n \tgvimdiff)\n \t\ttouch \"$BACKUP\"\n-\t\tgvimdiff -f -- \"$LOCAL\" \"$path\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -f -- \"$LOCAL\" \"$path\" \"$REMOTE\"\n \t\tcheck_unchanged\n \t\tsave_backup\n \t\t;;\n \txxdiff)\n \t    touch \"$BACKUP\"\n \t    if base_present ; then\n-\t\txxdiff -X --show-merged-pane \\\n+\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n \t\t    -R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n \t\t    -R 'Accel.Search: \"Ctrl+F\"' \\\n \t\t    -R 'Accel.SearchForward: \"Ctrl-G\"' \\\n \t\t    --merged-file \"$path\" -- \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \t    else\n-\t\txxdiff -X --show-merged-pane \\\n+\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n \t\t    -R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n \t\t    -R 'Accel.Search: \"Ctrl+F\"' \\\n \t\t    -R 'Accel.SearchForward: \"Ctrl-G\"' \\\n@@ -243,18 +243,18 @@ merge_file () {\n \topendiff)\n \t    touch \"$BACKUP\"\n \t    if base_present; then\n-\t\topendiff \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$path\" | cat\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$path\" | cat\n \t    else\n-\t\topendiff \"$LOCAL\" \"$REMOTE\" -merge \"$path\" | cat\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" -merge \"$path\" | cat\n \t    fi\n \t    check_unchanged\n \t    save_backup\n \t    ;;\n \temerge)\n \t    if base_present ; then\n-\t\temacs -f emerge-files-with-ancestor-command \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$(basename \"$path\")\"\n+\t\t\"$merge_tool_path\" -f emerge-files-with-ancestor-command \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$(basename \"$path\")\"\n \t    else\n-\t\temacs -f emerge-files-command \"$LOCAL\" \"$REMOTE\" \"$(basename \"$path\")\"\n+\t\t\"$merge_tool_path\" -f emerge-files-command \"$LOCAL\" \"$REMOTE\" \"$(basename \"$path\")\"\n \t    fi\n \t    status=$?\n \t    save_backup\n@@ -297,17 +297,38 @@ do\n     shift\n done\n \n+valid_tool() {\n+\tcase \"$1\" in\n+\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff)\n+\t\t\t;; # happy\n+\t\t*)\n+\t\t\treturn 1\n+\t\t\t;;\n+\tesac\n+}\n+\n+init_merge_tool_path() {\n+\tmerge_tool_path=`git config mergetool.$1.path`\n+\tif test -z \"$merge_tool_path\" ; then\n+\t\tcase \"$merge_tool\" in\n+\t\t\temerge)\n+\t\t\t\tmerge_tool_path=emacs\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmerge_tool_path=$merge_tool\n+\t\t\t\t;;\n+\t\tesac\n+\tfi\n+}\n+\n+\n if test -z \"$merge_tool\"; then\n     merge_tool=`git config merge.tool`\n-    case \"$merge_tool\" in\n-\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | \"\")\n-\t    ;; # happy\n-\t*)\n+    test -z \"$merge_tool\" || valid_tool \"$merge_tool\" || {\n \t    echo >&2 \"git config option merge.tool set to unknown tool: $merge_tool\"\n \t    echo >&2 \"Resetting to default...\"\n \t    unset merge_tool\n-\t    ;;\n-    esac\n+    }\n fi\n \n if test -z \"$merge_tool\" ; then\n@@ -329,40 +350,30 @@ if test -z \"$merge_tool\" ; then\n     merge_tool_candidates=\"$merge_tool_candidates opendiff emerge vimdiff\"\n     echo \"merge tool candidates: $merge_tool_candidates\"\n     for i in $merge_tool_candidates; do\n-        if test $i = emerge ; then\n-            cmd=emacs\n-        else\n-            cmd=$i\n-        fi\n-        if type $cmd > /dev/null 2>&1; then\n+        init_merge_tool_path $i\n+        if type \"$merge_tool_path\" > /dev/null 2>&1; then\n             merge_tool=$i\n             break\n         fi\n     done\n     if test -z \"$merge_tool\" ; then\n-\techo \"No available merge resolution programs available.\"\n+\techo \"No known merge resolution program available.\"\n \texit 1\n     fi\n+else\n+    valid_tool \"$merge_tool\" || {\n+        echo >&2 \"Unknown merge_tool $merge_tool\"\n+        exit 1\n+    }\n+\n+    init_merge_tool_path \"$merge_tool\"\n+\n+    if ! type \"$merge_tool_path\" > /dev/null 2>&1; then\n+        echo \"The merge tool $merge_tool is not available as '$merge_tool_path'\"\n+        exit 1\n+    fi\n fi\n \n-case \"$merge_tool\" in\n-    kdiff3|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-\tfi\n-\t;;\n-    emerge)\n-\tif ! type \"emacs\" > /dev/null 2>&1; then\n-\t    echo \"Emacs is not available\"\n-\t    exit 1\n-\tfi\n-\t;;\n-    *)\n-\techo \"Unknown merge tool: $merge_tool\"\n-\texit 1\n-\t;;\n-esac\n \n if test $# -eq 0 ; then\n \tfiles=`git ls-files -u | sed -e 's/^[^\t]*\t//' | sort -u`\n-- \n1.5.3.4.222.g2830\n"},{"id":"56371","messageId":"20071018080049.GK14735@spearce.org","threadId":"10345","inReplyTo":"923DDB10-C9E9-4797-9FC1-D31DEEBE75B7@zib.de","subject":"Re: [PATCH 1/2 v3] mergetool: use path to mergetool in config var mergetool.<tool>.path","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-10-18T08:00:49Z","receivedAt":"2007-10-18T08:00:49Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Steffen Prohaska <prohaska@zib.de> wrote:\n> On Oct 18, 2007, at 7:27 AM, Shawn O. Pearce wrote:\n> >...\n> >>+    test -n \"$merge_tool\" || valid_tool \"$merge_tool\" || {\n> >\n> >Wouldn't an empty $merge_tool string be caught above in the\n> >valid_tool function where it falls through and returns 1?\n> >So isn't test -n here redundant?\n> \n> Sharp eyes, thanks.\n> \n> Correct is\n> \n> test -z \"$merge_tool\" || valid_tool \"$merge_tool\" || {\n> \n> No merge tool or a valid merge tool is allowed at this place.\n> If the tool's already empty there's no need to tell the user\n> that it will be reset to empty.\n> \n> I'll send a v4 version.\n\nThanks but its a little late.  I'm about to push maint/master/next/pu\nand this series is in next.  While testing it I found another\nbug related to init_tool_merge_tool_path() not having $merge_tool\ninitialized and thus causing it to never select a default tool if\nthe user didn't have one configured.\n\nHere's what I'm actually about to push out:\n\n--8>--\nFrom e3fa2c761fdc490494e8e0855bcee4d7e58ada6a Mon Sep 17 00:00:00 2001\nFrom: Steffen Prohaska <prohaska@zib.de>\nDate: Wed, 17 Oct 2007 19:16:11 +0200\nSubject: [PATCH] mergetool: use path to mergetool in config var mergetool.<tool>.path\n\nThis commit adds a mechanism to provide absolute paths to the\nexternal programs called by 'git mergetool'. A path can be\nspecified in the configuation variable mergetool.<tool>.path.\nThe configuration variable is similar to how we name branches\nand remotes. It is extensible if we need to specify more details\nabout a tool.\n\nThe mechanism is especially useful on Windows, where external\nprograms are unlikely to be in PATH.\n\n[sp: Fixed a few minor issues prior to applying]\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n Documentation/git-mergetool.txt |    6 ++\n git-mergetool.sh                |   97 +++++++++++++++++++++-----------------\n 2 files changed, 60 insertions(+), 43 deletions(-)\n\ndiff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt\nindex 6c32c6d..78b2f43 100644\n--- a/Documentation/git-mergetool.txt\n+++ b/Documentation/git-mergetool.txt\n@@ -31,6 +31,12 @@ If a merge resolution program is not specified, 'git mergetool'\n will use the configuration variable merge.tool.  If the\n configuration variable merge.tool is not set, 'git mergetool'\n will pick a suitable default.\n++\n+You can explicitly provide a full path to the tool by setting the\n+configuration variable mergetool.<tool>.path. For example, you\n+can configure the absolute path to kdiff3 by setting\n+mergetool.kdiff3.path. Otherwise, 'git mergetool' assumes the tool\n+is available in PATH.\n \n Author\n ------\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 9f4f313..4f89cbe 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -192,10 +192,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(\"$merge_tool_path\" --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(\"$merge_tool_path\" --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@@ -203,35 +203,35 @@ merge_file () {\n \t    ;;\n \ttkdiff)\n \t    if base_present ; then\n-\t\ttkdiff -a \"$BASE\" -o \"$path\" -- \"$LOCAL\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -a \"$BASE\" -o \"$path\" -- \"$LOCAL\" \"$REMOTE\"\n \t    else\n-\t\ttkdiff -o \"$path\" -- \"$LOCAL\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -o \"$path\" -- \"$LOCAL\" \"$REMOTE\"\n \t    fi\n \t    status=$?\n \t    save_backup\n \t    ;;\n \tmeld|vimdiff)\n \t    touch \"$BACKUP\"\n-\t    $merge_tool -- \"$LOCAL\" \"$path\" \"$REMOTE\"\n+\t    \"$merge_tool_path\" -- \"$LOCAL\" \"$path\" \"$REMOTE\"\n \t    check_unchanged\n \t    save_backup\n \t    ;;\n \tgvimdiff)\n \t\ttouch \"$BACKUP\"\n-\t\tgvimdiff -f -- \"$LOCAL\" \"$path\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -f -- \"$LOCAL\" \"$path\" \"$REMOTE\"\n \t\tcheck_unchanged\n \t\tsave_backup\n \t\t;;\n \txxdiff)\n \t    touch \"$BACKUP\"\n \t    if base_present ; then\n-\t\txxdiff -X --show-merged-pane \\\n+\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n \t\t    -R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n \t\t    -R 'Accel.Search: \"Ctrl+F\"' \\\n \t\t    -R 'Accel.SearchForward: \"Ctrl-G\"' \\\n \t\t    --merged-file \"$path\" -- \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n \t    else\n-\t\txxdiff -X --show-merged-pane \\\n+\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n \t\t    -R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n \t\t    -R 'Accel.Search: \"Ctrl+F\"' \\\n \t\t    -R 'Accel.SearchForward: \"Ctrl-G\"' \\\n@@ -243,18 +243,18 @@ merge_file () {\n \topendiff)\n \t    touch \"$BACKUP\"\n \t    if base_present; then\n-\t\topendiff \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$path\" | cat\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$path\" | cat\n \t    else\n-\t\topendiff \"$LOCAL\" \"$REMOTE\" -merge \"$path\" | cat\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" -merge \"$path\" | cat\n \t    fi\n \t    check_unchanged\n \t    save_backup\n \t    ;;\n \temerge)\n \t    if base_present ; then\n-\t\temacs -f emerge-files-with-ancestor-command \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$(basename \"$path\")\"\n+\t\t\"$merge_tool_path\" -f emerge-files-with-ancestor-command \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$(basename \"$path\")\"\n \t    else\n-\t\temacs -f emerge-files-command \"$LOCAL\" \"$REMOTE\" \"$(basename \"$path\")\"\n+\t\t\"$merge_tool_path\" -f emerge-files-command \"$LOCAL\" \"$REMOTE\" \"$(basename \"$path\")\"\n \t    fi\n \t    status=$?\n \t    save_backup\n@@ -297,17 +297,38 @@ do\n     shift\n done\n \n+valid_tool() {\n+\tcase \"$1\" in\n+\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff)\n+\t\t\t;; # happy\n+\t\t*)\n+\t\t\treturn 1\n+\t\t\t;;\n+\tesac\n+}\n+\n+init_merge_tool_path() {\n+\tmerge_tool_path=`git config mergetool.$1.path`\n+\tif test -z \"$merge_tool_path\" ; then\n+\t\tcase \"$1\" in\n+\t\t\temerge)\n+\t\t\t\tmerge_tool_path=emacs\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tmerge_tool_path=$1\n+\t\t\t\t;;\n+\t\tesac\n+\tfi\n+}\n+\n+\n if test -z \"$merge_tool\"; then\n     merge_tool=`git config merge.tool`\n-    case \"$merge_tool\" in\n-\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | \"\")\n-\t    ;; # happy\n-\t*)\n+    if ! valid_tool \"$merge_tool\"; then\n \t    echo >&2 \"git config option merge.tool set to unknown tool: $merge_tool\"\n \t    echo >&2 \"Resetting to default...\"\n \t    unset merge_tool\n-\t    ;;\n-    esac\n+    fi\n fi\n \n if test -z \"$merge_tool\" ; then\n@@ -329,40 +350,30 @@ if test -z \"$merge_tool\" ; then\n     merge_tool_candidates=\"$merge_tool_candidates opendiff emerge vimdiff\"\n     echo \"merge tool candidates: $merge_tool_candidates\"\n     for i in $merge_tool_candidates; do\n-        if test $i = emerge ; then\n-            cmd=emacs\n-        else\n-            cmd=$i\n-        fi\n-        if type $cmd > /dev/null 2>&1; then\n+        init_merge_tool_path $i\n+        if type \"$merge_tool_path\" > /dev/null 2>&1; then\n             merge_tool=$i\n             break\n         fi\n     done\n     if test -z \"$merge_tool\" ; then\n-\techo \"No available merge resolution programs available.\"\n+\techo \"No known merge resolution program available.\"\n \texit 1\n     fi\n+else\n+    if ! valid_tool \"$merge_tool\"; then\n+        echo >&2 \"Unknown merge_tool $merge_tool\"\n+        exit 1\n+    fi\n+\n+    init_merge_tool_path \"$merge_tool\"\n+\n+    if ! type \"$merge_tool_path\" > /dev/null 2>&1; then\n+        echo \"The merge tool $merge_tool is not available as '$merge_tool_path'\"\n+        exit 1\n+    fi\n fi\n \n-case \"$merge_tool\" in\n-    kdiff3|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-\tfi\n-\t;;\n-    emerge)\n-\tif ! type \"emacs\" > /dev/null 2>&1; then\n-\t    echo \"Emacs is not available\"\n-\t    exit 1\n-\tfi\n-\t;;\n-    *)\n-\techo \"Unknown merge tool: $merge_tool\"\n-\texit 1\n-\t;;\n-esac\n \n if test $# -eq 0 ; then\n \tfiles=`git ls-files -u | sed -e 's/^[^\t]*\t//' | sort -u`\n-- \n1.5.3.4.1231.gac645\n\n\n-- \nShawn.\n"},{"id":"56376","messageId":"4591BA15-EB6B-4058-A2D0-879556481E59@zib.de","threadId":"10345","inReplyTo":"20071018080049.GK14735@spearce.org","subject":"Re: [PATCH 1/2 v3] mergetool: use path to mergetool in config var mergetool.<tool>.path","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-10-18T08:40:09Z","receivedAt":"2007-10-18T08:40:09Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Oct 18, 2007, at 10:00 AM, Shawn O. Pearce wrote:\n\n> Steffen Prohaska <prohaska@zib.de> wrote:\n>> On Oct 18, 2007, at 7:27 AM, Shawn O. Pearce wrote:\n>>> ...\n>>>> +    test -n \"$merge_tool\" || valid_tool \"$merge_tool\" || {\n>>>\n>>> Wouldn't an empty $merge_tool string be caught above in the\n>>> valid_tool function where it falls through and returns 1?\n>>> So isn't test -n here redundant?\n>>\n>> Sharp eyes, thanks.\n>>\n>> Correct is\n>>\n>> test -z \"$merge_tool\" || valid_tool \"$merge_tool\" || {\n>>\n>> No merge tool or a valid merge tool is allowed at this place.\n>> If the tool's already empty there's no need to tell the user\n>> that it will be reset to empty.\n>>\n>> I'll send a v4 version.\n>\n> Thanks but its a little late.\n\nSorry.\n\n\n> I'm about to push maint/master/next/pu\n> and this series is in next.  While testing it I found another\n> bug related to init_tool_merge_tool_path() not having $merge_tool\n> initialized and thus causing it to never select a default tool if\n> the user didn't have one configured.\n\nI see. Thanks for fixing this.\n\n\n> Here's what I'm actually about to push out:\n\nOne remark ...\n\n[...]\n>\n>  if test -z \"$merge_tool\"; then\n>      merge_tool=`git config merge.tool`\n> -    case \"$merge_tool\" in\n> -\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff |  \n> gvimdiff | \"\")\n> -\t    ;; # happy\n> -\t*)\n> +    if ! valid_tool \"$merge_tool\"; then\n\nI think its ok to have an empty tool here ...\n\n>  \t    echo >&2 \"git config option merge.tool set to unknown tool:  \n> $merge_tool\"\n>  \t    echo >&2 \"Resetting to default...\"\n\n... So we should not print this message if the tool is empty.\n\nBut an empty tool is not valid. Therefore a check if \"$merge_tool\"\nis not empty should be added to the if.\n\n\tSteffen\n"},{"id":"56380","messageId":"11927031342272-git-send-email-prohaska@zib.de","threadId":"10345","inReplyTo":"4591BA15-EB6B-4058-A2D0-879556481E59@zib.de","subject":"[PATCH] mergetool: avoid misleading message \"Resetting to default...\"","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-10-18T10:25:34Z","receivedAt":"2007-10-18T10:25:34Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"If no mergetool is configured in the configuration variable\nmerge.tool the resetting message should not be printed.\n\nThis is fixed. The message is only printed if a tool is configured\nbut the entry in merge.tool is invalid.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n git-mergetool.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 94511f9..a68b403 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -334,7 +334,7 @@ init_merge_tool_path() {\n \n if test -z \"$merge_tool\"; then\n     merge_tool=`git config merge.tool`\n-    if ! valid_tool \"$merge_tool\"; then\n+    if test -n \"$merge_tool\" && ! valid_tool \"$merge_tool\"; then\n \t    echo >&2 \"git config option merge.tool set to unknown tool: $merge_tool\"\n \t    echo >&2 \"Resetting to default...\"\n \t    unset merge_tool\n-- \n1.5.3.4.222.g2830\n"}]}