{"thread":{"id":"18744","subject":"[PATCH 02/14] git-mergetool/difftool: make (g)vimdiff workable under Windows","startedAt":"2009-04-06T08:31:15Z","lastAt":"2009-04-06T23:42:38Z","messageCount":17,"participants":["David Aguilar","Markus Heidelberg"],"isPatch":true,"patchVersion":1,"patchTotal":14},"messages":[{"id":"110534","messageId":"1239006689-14695-1-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":null,"subject":"git-{merge,diff}tool refactor round three","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:15Z","receivedAt":"2009-04-06T08:31:15Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Hopefully this is the final round =)\n\nThis series is based on top of master.\n\nThe result of this series gets us to where da/difftool in pu\narrived, but does so in a maintainer-friendly way.\n\nI'm including Markus' patches in this series just so that it's\nclear that this series is dependent on it.\n\nEverything before \"move 'git-difftool' out of contrib\" can be\napplied to master directly since it is not involved in the\nrefactor.\n\nWe'll need to revert:\n\td3b8cec difftool: move 'git-difftool' out of contrib\nto avoid a merge conflict in next.\n\n\nIn case anyone's curious, da/difftool originally\ncontained 25 commits.  Less is more.\n"},{"id":"110531","messageId":"1239006689-14695-2-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-1-git-send-email-davvid@gmail.com","subject":"[PATCH 01/14] doc/merge-config: list ecmerge as a built-in merge tool","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:16Z","receivedAt":"2009-04-06T08:31:16Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"From: Markus Heidelberg <markus.heidelberg@web.de>\n\nSigned-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n---\n Documentation/merge-config.txt |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/merge-config.txt b/Documentation/merge-config.txt\nindex 1ff08ff..9c44af8 100644\n--- a/Documentation/merge-config.txt\n+++ b/Documentation/merge-config.txt\n@@ -22,7 +22,8 @@ merge.stat::\n merge.tool::\n \tControls which merge resolution program is used by\n \tlinkgit:git-mergetool[1].  Valid built-in values are: \"kdiff3\",\n-\t\"tkdiff\", \"meld\", \"xxdiff\", \"emerge\", \"vimdiff\", \"gvimdiff\", and\n+\t\"tkdiff\", \"meld\", \"xxdiff\", \"emerge\", \"vimdiff\", \"gvimdiff\",\n+\t\"ecmerge\" and\n \t\"opendiff\".  Any other value is treated is custom merge tool\n \tand there must be a corresponding mergetool.<tool>.cmd option.\n \n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110530","messageId":"1239006689-14695-3-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-2-git-send-email-davvid@gmail.com","subject":"[PATCH 02/14] git-mergetool/difftool: make (g)vimdiff workable under Windows","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:17Z","receivedAt":"2009-04-06T08:31:17Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"From: Markus Heidelberg <markus.heidelberg@web.de>\n\nUnder Windows vimdiff and gvimdiff are not available as symbolic links,\nbut as batch files vimdiff.bat and gvimdiff.bat. These files weren't\nfound by 'type vimdiff' which led to the following error:\n\n    The merge tool vimdiff is not available as 'vimdiff'\n\nEven if they were found, it wouldn't work to invoke these batch files\nfrom git-mergetool.\n\nTo solve this, use vim and gvim (vim.exe and gvim.exe) and pass the -d\ncommand line switch over to them.\n\nSigned-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n---\n contrib/difftool/git-difftool-helper |   10 ++++++++--\n git-mergetool.sh                     |   10 ++++++++--\n 2 files changed, 16 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/difftool/git-difftool-helper b/contrib/difftool/git-difftool-helper\nindex 9c0a134..e481913 100755\n--- a/contrib/difftool/git-difftool-helper\n+++ b/contrib/difftool/git-difftool-helper\n@@ -86,11 +86,11 @@ launch_merge_tool () {\n \t\t;;\n \n \tvimdiff)\n-\t\t\"$merge_tool_path\" -c \"wincmd l\" \"$LOCAL\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -d -c \"wincmd l\" \"$LOCAL\" \"$REMOTE\"\n \t\t;;\n \n \tgvimdiff)\n-\t\t\"$merge_tool_path\" -c \"wincmd l\" -f \"$LOCAL\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" -d -c \"wincmd l\" -f \"$LOCAL\" \"$REMOTE\"\n \t\t;;\n \n \txxdiff)\n@@ -160,6 +160,12 @@ 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\tvimdiff)\n+\t\t\tmerge_tool_path=vim\n+\t\t\t;;\n+\t\tgvimdiff)\n+\t\t\tmerge_tool_path=gvim\n+\t\t\t;;\n \t\temerge)\n \t\t\tmerge_tool_path=emacs\n \t\t\t;;\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 87fa88a..6e611e9 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -214,12 +214,12 @@ merge_file () {\n \t    ;;\n \tvimdiff)\n \t    touch \"$BACKUP\"\n-\t    \"$merge_tool_path\" -c \"wincmd l\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t    \"$merge_tool_path\" -d -c \"wincmd l\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \t    check_unchanged\n \t    ;;\n \tgvimdiff)\n \t    touch \"$BACKUP\"\n-\t    \"$merge_tool_path\" -c \"wincmd l\" -f \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t    \"$merge_tool_path\" -d -c \"wincmd l\" -f \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n \t    check_unchanged\n \t    ;;\n \txxdiff)\n@@ -359,6 +359,12 @@ 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\tvimdiff)\n+\t\t\t\tmerge_tool_path=vim\n+\t\t\t\t;;\n+\t\t\tgvimdiff)\n+\t\t\t\tmerge_tool_path=gvim\n+\t\t\t\t;;\n \t\t\temerge)\n \t\t\t\tmerge_tool_path=emacs\n \t\t\t\t;;\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110535","messageId":"1239006689-14695-4-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-3-git-send-email-davvid@gmail.com","subject":"[PATCH 03/14] git-mergetool: add new merge tool TortoiseMerge","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:18Z","receivedAt":"2009-04-06T08:31:18Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"From: Markus Heidelberg <markus.heidelberg@web.de>\n\nTortoiseMerge comes with TortoiseSVN or TortoiseGit for Windows. It can\nonly be used as a merge tool with an existing base file. It cannot be\nused without a base nor as a diff tool.\n\nThe documentation only mentions the slash '/' as command line option\nprefix, which refused to work, but the parser also accepts the dash '-'\n\nSee http://code.google.com/p/msysgit/issues/detail?id=226\n\nSigned-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n---\n Documentation/git-mergetool.txt |    3 ++-\n Documentation/merge-config.txt  |    2 +-\n git-mergetool.sh                |   16 +++++++++++++---\n 3 files changed, 16 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt\nindex 5d3c632..5edac4d 100644\n--- a/Documentation/git-mergetool.txt\n+++ b/Documentation/git-mergetool.txt\n@@ -26,7 +26,8 @@ OPTIONS\n --tool=<tool>::\n \tUse the merge resolution program specified by <tool>.\n \tValid merge tools are:\n-\tkdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff\n+\tkdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge,\n+\ttortoisemerge 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/Documentation/merge-config.txt b/Documentation/merge-config.txt\nindex 9c44af8..8c10f66 100644\n--- a/Documentation/merge-config.txt\n+++ b/Documentation/merge-config.txt\n@@ -23,7 +23,7 @@ merge.tool::\n \tControls which merge resolution program is used by\n \tlinkgit:git-mergetool[1].  Valid built-in values are: \"kdiff3\",\n \t\"tkdiff\", \"meld\", \"xxdiff\", \"emerge\", \"vimdiff\", \"gvimdiff\",\n-\t\"ecmerge\" and\n+\t\"ecmerge\", tortoisemerge and\n \t\"opendiff\".  Any other value is treated is custom merge tool\n \tand there must be a corresponding mergetool.<tool>.cmd option.\n \ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex 6e611e9..be9717a 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -265,6 +265,16 @@ merge_file () {\n \t    fi\n \t    status=$?\n \t    ;;\n+\ttortoisemerge)\n+\t    if base_present ; then\n+\t\ttouch \"$BACKUP\"\n+\t\t\"$merge_tool_path\" -base:\"$BASE\" -mine:\"$LOCAL\" -theirs:\"$REMOTE\" -merged:\"$MERGED\"\n+\t\tcheck_unchanged\n+\t    else\n+\t\techo \"TortoiseMerge cannot be used without a base\" 1>&2\n+\t\tstatus=1\n+\t    fi\n+\t    ;;\n \t*)\n \t    if test -n \"$merge_tool_cmd\"; then\n \t\tif test \"$merge_tool_trust_exit_code\" = \"false\"; then\n@@ -345,7 +355,7 @@ valid_custom_tool()\n \n valid_tool() {\n \tcase \"$1\" in\n-\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)\n+\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge | tortoisemerge)\n \t\t\t;; # happy\n \t\t*)\n \t\t\tif ! valid_custom_tool \"$1\"; then\n@@ -404,9 +414,9 @@ fi\n if test -z \"$merge_tool\" ; then\n     if test -n \"$DISPLAY\"; then\n         if test -n \"$GNOME_DESKTOP_SESSION_ID\" ; then\n-            merge_tool_candidates=\"meld kdiff3 tkdiff xxdiff gvimdiff\"\n+            merge_tool_candidates=\"meld kdiff3 tkdiff xxdiff tortoisemerge gvimdiff\"\n         else\n-            merge_tool_candidates=\"kdiff3 tkdiff xxdiff meld gvimdiff\"\n+            merge_tool_candidates=\"kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff\"\n         fi\n     fi\n     if echo \"${VISUAL:-$EDITOR}\" | grep 'emacs' > /dev/null 2>&1; then\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110536","messageId":"1239006689-14695-5-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-4-git-send-email-davvid@gmail.com","subject":"[PATCH 04/14] difftool: remove merge options for opendiff, tkdiff, kdiff3 and xxdiff","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:19Z","receivedAt":"2009-04-06T08:31:19Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"We shouldn't try to merge files when using difftool, so remove\nany merge-specific options.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n contrib/difftool/git-difftool-helper |   10 +++-------\n 1 files changed, 3 insertions(+), 7 deletions(-)\n\ndiff --git a/contrib/difftool/git-difftool-helper b/contrib/difftool/git-difftool-helper\nindex e481913..ef684b6 100755\n--- a/contrib/difftool/git-difftool-helper\n+++ b/contrib/difftool/git-difftool-helper\n@@ -69,7 +69,7 @@ launch_merge_tool () {\n \t\t\"$merge_tool_path\" --auto \\\n \t\t\t--L1 \"$basename (A)\" \\\n \t\t\t--L2 \"$basename (B)\" \\\n-\t\t\t-o \"$MERGED\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\"$LOCAL\" \"$REMOTE\" \\\n \t\t\t> /dev/null 2>&1\n \t\t;;\n \n@@ -78,7 +78,7 @@ launch_merge_tool () {\n \t\t;;\n \n \ttkdiff)\n-\t\t\"$merge_tool_path\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\"\n \t\t;;\n \n \tmeld)\n@@ -95,17 +95,13 @@ launch_merge_tool () {\n \n \txxdiff)\n \t\t\"$merge_tool_path\" \\\n-\t\t\t-X \\\n-\t\t\t-R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n \t\t\t-R 'Accel.Search: \"Ctrl+F\"' \\\n \t\t\t-R 'Accel.SearchForward: \"Ctrl-G\"' \\\n-\t\t\t--merged-file \"$MERGED\" \\\n \t\t\t\"$LOCAL\" \"$REMOTE\"\n \t\t;;\n \n \topendiff)\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n-\t\t\t-merge \"$MERGED\" | cat\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" | cat\n \t\t;;\n \n \tecmerge)\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110533","messageId":"1239006689-14695-6-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-5-git-send-email-davvid@gmail.com","subject":"[PATCH 05/14] difftool: remove the backup file feature","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:20Z","receivedAt":"2009-04-06T08:31:20Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Most users find the backup file feature annoying and there's no\nneed for it since diff is supposed to be a read-only operation.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n contrib/difftool/git-difftool-helper |   34 +---------------------------------\n 1 files changed, 1 insertions(+), 33 deletions(-)\n\ndiff --git a/contrib/difftool/git-difftool-helper b/contrib/difftool/git-difftool-helper\nindex ef684b6..e74a274 100755\n--- a/contrib/difftool/git-difftool-helper\n+++ b/contrib/difftool/git-difftool-helper\n@@ -9,31 +9,7 @@\n \n # Set GIT_DIFFTOOL_NO_PROMPT to bypass the per-file prompt.\n should_prompt () {\n-\t! test -n \"$GIT_DIFFTOOL_NO_PROMPT\"\n-}\n-\n-# Should we keep the backup .orig file?\n-keep_backup_mode=\"$(git config --bool merge.keepBackup || echo true)\"\n-keep_backup () {\n-\ttest \"$keep_backup_mode\" = \"true\"\n-}\n-\n-# This function manages the backup .orig file.\n-# A backup $MERGED.orig file is created if changes are detected.\n-cleanup_temp_files () {\n-\tif test -n \"$MERGED\"; then\n-\t\tif keep_backup && test \"$MERGED\" -nt \"$BACKUP\"; then\n-\t\t\ttest -f \"$BACKUP\" && mv -- \"$BACKUP\" \"$MERGED.orig\"\n-\t\telse\n-\t\t\trm -f -- \"$BACKUP\"\n-\t\tfi\n-\tfi\n-}\n-\n-# This is called when users Ctrl-C out of git-difftool-helper\n-sigint_handler () {\n-\tcleanup_temp_files\n-\texit 1\n+\ttest -z \"$GIT_DIFFTOOL_NO_PROMPT\"\n }\n \n # This function prepares temporary files and launches the appropriate\n@@ -47,12 +23,6 @@ launch_merge_tool () {\n \tLOCAL=\"$2\"\n \tREMOTE=\"$3\"\n \tBASE=\"$1\"\n-\text=\"$$$(expr \"$MERGED\" : '.*\\(\\.[^/]*\\)$')\"\n-\tBACKUP=\"$MERGED.BACKUP.$ext\"\n-\n-\t# Create and ensure that we clean up $BACKUP\n-\ttest -f \"$MERGED\" && cp -- \"$MERGED\" \"$BACKUP\"\n-\ttrap sigint_handler INT\n \n \t# $LOCAL and $REMOTE are temporary files so prompt\n \t# the user with the real $MERGED name before launching $merge_tool.\n@@ -120,8 +90,6 @@ launch_merge_tool () {\n \t\tfi\n \t\t;;\n \tesac\n-\n-\tcleanup_temp_files\n }\n \n # Verifies that (difftool|mergetool).<tool>.cmd exists\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110532","messageId":"1239006689-14695-7-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-6-git-send-email-davvid@gmail.com","subject":"[PATCH 06/14] difftool: use perl built-ins when testing for msys","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:21Z","receivedAt":"2009-04-06T08:31:21Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"I don't even know what $COMSPEC means so let's be safe and use the\nsame perly $^O test add--interactive uses.  While we're at it, make\ngit-difftool match the prevalent git-perl style.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n contrib/difftool/git-difftool |    7 +++++--\n 1 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/difftool/git-difftool b/contrib/difftool/git-difftool\nindex 0deda3a..207dd50 100755\n--- a/contrib/difftool/git-difftool\n+++ b/contrib/difftool/git-difftool\n@@ -33,7 +33,10 @@ sub setup_environment\n sub exe\n {\n \tmy $exe = shift;\n-\treturn defined $ENV{COMSPEC} ? \"$exe.exe\" : $exe;\n+\tif ($^O eq 'MSWin32' || $^O eq 'msys') {\n+\t\treturn \"$exe.exe\";\n+\t}\n+\treturn $exe;\n }\n \n sub generate_command\n@@ -47,7 +50,7 @@ sub generate_command\n \t\t\t$skip_next = 0;\n \t\t\tnext;\n \t\t}\n-\t\tif ($arg eq '-t' or $arg eq '--tool') {\n+\t\tif ($arg eq '-t' || $arg eq '--tool') {\n \t\t\tusage() if $#ARGV <= $idx;\n \t\t\t$ENV{GIT_DIFF_TOOL} = $ARGV[$idx + 1];\n \t\t\t$skip_next = 1;\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110540","messageId":"1239006689-14695-8-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-7-git-send-email-davvid@gmail.com","subject":"[PATCH 07/14] difftool: add a -y shortcut for --no-prompt","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:22Z","receivedAt":"2009-04-06T08:31:22Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"This is another consistency cleanup to make git-difftool's options\nmatch git-mergetool.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n contrib/difftool/git-difftool     |    6 +++---\n contrib/difftool/git-difftool.txt |   36 ++++++++++++++----------------------\n 2 files changed, 17 insertions(+), 25 deletions(-)\n\ndiff --git a/contrib/difftool/git-difftool b/contrib/difftool/git-difftool\nindex 207dd50..8c160e5 100755\n--- a/contrib/difftool/git-difftool\n+++ b/contrib/difftool/git-difftool\n@@ -18,7 +18,7 @@ my $DIR = abs_path(dirname($0));\n sub usage\n {\n \tprint << 'USAGE';\n-usage: git difftool [--tool=<tool>] [--no-prompt] [\"git diff\" options]\n+usage: git difftool [--tool=<tool>] [-y|--no-prompt] [\"git diff\" options]\n USAGE\n \texit 1;\n }\n@@ -60,11 +60,11 @@ sub generate_command\n \t\t\t$ENV{GIT_DIFF_TOOL} = substr($arg, 7);\n \t\t\tnext;\n \t\t}\n-\t\tif ($arg eq '--no-prompt') {\n+\t\tif ($arg eq '-y' || $arg eq '--no-prompt') {\n \t\t\t$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';\n \t\t\tnext;\n \t\t}\n-\t\tif ($arg eq '-h' or $arg eq '--help') {\n+\t\tif ($arg eq '-h' || $arg eq '--help') {\n \t\t\tusage();\n \t\t}\n \t\tpush @command, $arg;\ndiff --git a/contrib/difftool/git-difftool.txt b/contrib/difftool/git-difftool.txt\nindex 2b7bc03..4dff529 100644\n--- a/contrib/difftool/git-difftool.txt\n+++ b/contrib/difftool/git-difftool.txt\n@@ -3,35 +3,32 @@ git-difftool(1)\n \n NAME\n ----\n-git-difftool - compare changes using common merge tools\n+git-difftool - Show changes using common diff tools\n \n SYNOPSIS\n --------\n-'git difftool' [--tool=<tool>] [--no-prompt] ['git diff' options]\n+'git difftool' [-t|--tool=<tool>] [-y|--no-prompt] [<'git diff' options>]\n \n DESCRIPTION\n -----------\n 'git-difftool' is a git command that allows you to compare and edit files\n-between revisions using common merge tools.  At its most basic level,\n-'git-difftool' does what 'git-mergetool' does but its use is for non-merge\n-situations such as when preparing commits or comparing changes against\n-the index.\n-\n-'git difftool' is a frontend to 'git diff' and accepts the same\n-arguments and options.\n-\n-See linkgit:git-diff[1] for the full list of supported options.\n+between revisions using common diff tools.  'git difftool' is a frontend\n+to 'git-diff' and accepts the same options and arguments.\n \n OPTIONS\n -------\n+-y::\n+--no-prompt::\n+\tDo not prompt before launching a diff tool.\n+\n -t <tool>::\n --tool=<tool>::\n-\tUse the merge resolution program specified by <tool>.\n+\tUse the diff tool specified by <tool>.\n \tValid merge tools are:\n \tkdiff3, kompare, tkdiff, meld, xxdiff, emerge,\n \tvimdiff, gvimdiff, ecmerge, and opendiff\n +\n-If a merge resolution program is not specified, 'git-difftool'\n+If a diff tool is not specified, 'git-difftool'\n will use the configuration variable `diff.tool`.  If the\n configuration variable `diff.tool` is not set, 'git-difftool'\n will pick a suitable default.\n@@ -42,7 +39,7 @@ can configure the absolute path to kdiff3 by setting\n `difftool.kdiff3.path`. Otherwise, 'git-difftool' assumes the\n tool is available in PATH.\n +\n-Instead of running one of the known merge tool programs,\n+Instead of running one of the known diff tools,\n 'git-difftool' can be customized to run an alternative program\n by specifying the command line to invoke in a configuration\n variable `difftool.<tool>.cmd`.\n@@ -56,8 +53,7 @@ is set to the name of the temporary file containing the contents\n of the diff post-image.  `$BASE` is provided for compatibility\n with custom merge tool commands and has the same value as `$LOCAL`.\n \n---no-prompt::\n-\tDo not prompt before launching a diff tool.\n+See linkgit:git-diff[1] for the full list of supported options.\n \n CONFIG VARIABLES\n ----------------\n@@ -65,21 +61,17 @@ CONFIG VARIABLES\n difftool equivalents have not been defined.\n \n diff.tool::\n-\tThe default merge tool to use.\n+\tThe default diff tool to use.\n \n difftool.<tool>.path::\n \tOverride the path for the given tool.  This is useful in case\n \tyour tool is not in the PATH.\n \n difftool.<tool>.cmd::\n-\tSpecify the command to invoke the specified merge tool.\n+\tSpecify the command to invoke the specified diff tool.\n +\n See the `--tool=<tool>` option above for more details.\n \n-merge.keepBackup::\n-\tThe original, unedited file content can be saved to a file with\n-\ta `.orig` extension.  Defaults to `true` (i.e. keep the backup files).\n-\n SEE ALSO\n --------\n linkgit:git-diff[1]::\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110537","messageId":"1239006689-14695-9-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-8-git-send-email-davvid@gmail.com","subject":"[PATCH 08/14] difftool/mergetool: add diffuse as merge and diff tool","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:23Z","receivedAt":"2009-04-06T08:31:23Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"From: Sebastian Pipping <sebastian@pipping.org>\n\nThis adds diffuse as a built-in merge tool.\n\nSigned-off-by: Sebastian Pipping <sebastian@pipping.org>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n Documentation/git-mergetool.txt        |    2 +-\n Documentation/merge-config.txt         |    2 +-\n contrib/completion/git-completion.bash |    3 ++-\n contrib/difftool/git-difftool-helper   |   10 ++++++----\n contrib/difftool/git-difftool.txt      |    4 ++--\n git-mergetool.sh                       |    4 ++--\n 6 files changed, 14 insertions(+), 11 deletions(-)\n\ndiff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt\nindex 5edac4d..ff9700d 100644\n--- a/Documentation/git-mergetool.txt\n+++ b/Documentation/git-mergetool.txt\n@@ -27,7 +27,7 @@ OPTIONS\n \tUse the merge resolution program specified by <tool>.\n \tValid merge tools are:\n \tkdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge,\n-\ttortoisemerge and opendiff\n+\tdiffuse, tortoisemerge 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/Documentation/merge-config.txt b/Documentation/merge-config.txt\nindex 8c10f66..4832bc7 100644\n--- a/Documentation/merge-config.txt\n+++ b/Documentation/merge-config.txt\n@@ -23,7 +23,7 @@ merge.tool::\n \tControls which merge resolution program is used by\n \tlinkgit:git-mergetool[1].  Valid built-in values are: \"kdiff3\",\n \t\"tkdiff\", \"meld\", \"xxdiff\", \"emerge\", \"vimdiff\", \"gvimdiff\",\n-\t\"ecmerge\", tortoisemerge and\n+\t\"diffuse\", \"ecmerge\", \"tortoisemerge\", and\n \t\"opendiff\".  Any other value is treated is custom merge tool\n \tand there must be a corresponding mergetool.<tool>.cmd option.\n \ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e72ce24..4fcd77a 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1173,7 +1173,8 @@ _git_mergetool ()\n \t--tool=*)\n \t\t__gitcomp \"\n \t\t\tkdiff3 tkdiff meld xxdiff emerge\n-\t\t\tvimdiff gvimdiff ecmerge opendiff\n+\t\t\tvimdiff gvimdiff ecmerge diffuse\n+\t\t\topendiff\n \t\t\t\" \"\" \"${cur##--tool=}\"\n \t\treturn\n \t\t;;\ndiff --git a/contrib/difftool/git-difftool-helper b/contrib/difftool/git-difftool-helper\nindex e74a274..4b0daec 100755\n--- a/contrib/difftool/git-difftool-helper\n+++ b/contrib/difftool/git-difftool-helper\n@@ -1,7 +1,5 @@\n #!/bin/sh\n # git-difftool-helper is a GIT_EXTERNAL_DIFF-compatible diff tool launcher.\n-# It supports kdiff3, kompare, tkdiff, xxdiff, meld, opendiff,\n-# emerge, ecmerge, vimdiff, gvimdiff, and custom user-configurable tools.\n # This script is typically launched by using the 'git difftool'\n # convenience command.\n #\n@@ -55,6 +53,10 @@ launch_merge_tool () {\n \t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\"\n \t\t;;\n \n+\tdiffuse)\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" | cat\n+\t\t;;\n+\n \tvimdiff)\n \t\t\"$merge_tool_path\" -d -c \"wincmd l\" \"$LOCAL\" \"$REMOTE\"\n \t\t;;\n@@ -164,9 +166,9 @@ if test -z \"$merge_tool\"; then\n \tif test -n \"$DISPLAY\"; then\n \t\t# If gnome then prefer meld, otherwise, prefer kdiff3 or kompare\n \t\tif test -n \"$GNOME_DESKTOP_SESSION_ID\" ; then\n-\t\t\tmerge_tool_candidates=\"meld kdiff3 kompare tkdiff xxdiff gvimdiff\"\n+\t\t\tmerge_tool_candidates=\"meld kdiff3 kompare tkdiff xxdiff gvimdiff diffuse\"\n \t\telse\n-\t\t\tmerge_tool_candidates=\"kdiff3 kompare tkdiff xxdiff meld gvimdiff\"\n+\t\t\tmerge_tool_candidates=\"kdiff3 kompare tkdiff xxdiff meld gvimdiff diffuse\"\n \t\tfi\n \tfi\n \tif echo \"${VISUAL:-$EDITOR}\" | grep 'emacs' > /dev/null 2>&1; then\ndiff --git a/contrib/difftool/git-difftool.txt b/contrib/difftool/git-difftool.txt\nindex 4dff529..a2fa474 100644\n--- a/contrib/difftool/git-difftool.txt\n+++ b/contrib/difftool/git-difftool.txt\n@@ -25,8 +25,8 @@ OPTIONS\n --tool=<tool>::\n \tUse the diff tool specified by <tool>.\n \tValid merge tools are:\n-\tkdiff3, kompare, tkdiff, meld, xxdiff, emerge,\n-\tvimdiff, gvimdiff, ecmerge, and opendiff\n+\tkdiff3, kompare, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff,\n+\tecmerge, diffuse and opendiff\n +\n If a diff tool is not specified, 'git-difftool'\n will use the configuration variable `diff.tool`.  If the\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex be9717a..b4d2432 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -414,9 +414,9 @@ fi\n if test -z \"$merge_tool\" ; then\n     if test -n \"$DISPLAY\"; then\n         if test -n \"$GNOME_DESKTOP_SESSION_ID\" ; then\n-            merge_tool_candidates=\"meld kdiff3 tkdiff xxdiff tortoisemerge gvimdiff\"\n+            merge_tool_candidates=\"meld kdiff3 tkdiff xxdiff tortoisemerge gvimdiff diffuse\"\n         else\n-            merge_tool_candidates=\"kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff\"\n+            merge_tool_candidates=\"kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse\"\n         fi\n     fi\n     if echo \"${VISUAL:-$EDITOR}\" | grep 'emacs' > /dev/null 2>&1; then\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110539","messageId":"1239006689-14695-10-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-9-git-send-email-davvid@gmail.com","subject":"[PATCH 09/14] difftool: move 'git-difftool' out of contrib","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:24Z","receivedAt":"2009-04-06T08:31:24Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"This prepares 'git-difftool' and its documentation for\nmainstream use.\n\n'git-difftool-helper' became 'git-difftool--helper'\nsince users should not use it directly.\n\n'git-difftool' was added to the list of commands as\nan ancillaryinterrogator.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n .gitignore                                         |    2 ++\n Documentation/config.txt                           |   17 +++++++++++++++++\n .../difftool => Documentation}/git-difftool.txt    |    0\n Makefile                                           |    2 ++\n command-list.txt                                   |    1 +\n .../git-difftool-helper => git-difftool--helper.sh |    2 +-\n contrib/difftool/git-difftool => git-difftool.perl |    6 +++---\n 7 files changed, 26 insertions(+), 4 deletions(-)\n rename {contrib/difftool => Documentation}/git-difftool.txt (100%)\n rename contrib/difftool/git-difftool-helper => git-difftool--helper.sh (98%)\n rename contrib/difftool/git-difftool => git-difftool.perl (92%)\n\ndiff --git a/.gitignore b/.gitignore\nindex 1c57d4c..a36da9d 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -35,6 +35,8 @@ git-diff\n git-diff-files\n git-diff-index\n git-diff-tree\n+git-difftool\n+git-difftool--helper\n git-describe\n git-fast-export\n git-fast-import\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex ad22cb8..185a9ef 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -667,6 +667,23 @@ diff.suppressBlankEmpty::\n \tA boolean to inhibit the standard behavior of printing a space\n \tbefore each empty output line. Defaults to false.\n \n+diff.tool::\n+\tControls which diff tool is used.  `diff.tool` overrides\n+\t`merge.tool` when used by linkgit:git-difftool[1] and has\n+\tthe same valid values as `merge.tool`.\n+\n+difftool.<tool>.path::\n+\tOverride the path for the given tool.  This is useful in case\n+\tyour tool is not in the PATH.\n+\n+difftool.<tool>.cmd::\n+\tSpecify the command to invoke the specified diff tool.\n+\tThe specified command is evaluated in shell with the following\n+\tvariables available:  'LOCAL' is set to the name of the temporary\n+\tfile containing the contents of the diff pre-image and 'REMOTE'\n+\tis set to the name of the temporary file containing the contents\n+\tof the diff post-image.\n+\n diff.wordRegex::\n \tA POSIX Extended Regular Expression used to determine what is a \"word\"\n \twhen performing word-by-word difference calculations.  Character\ndiff --git a/contrib/difftool/git-difftool.txt b/Documentation/git-difftool.txt\nsimilarity index 100%\nrename from contrib/difftool/git-difftool.txt\nrename to Documentation/git-difftool.txt\ndiff --git a/Makefile b/Makefile\nindex 7867eac..a80055f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -277,6 +277,7 @@ TEST_PROGRAMS =\n \n SCRIPT_SH += git-am.sh\n SCRIPT_SH += git-bisect.sh\n+SCRIPT_SH += git-difftool--helper.sh\n SCRIPT_SH += git-filter-branch.sh\n SCRIPT_SH += git-lost-found.sh\n SCRIPT_SH += git-merge-octopus.sh\n@@ -296,6 +297,7 @@ SCRIPT_SH += git-submodule.sh\n SCRIPT_SH += git-web--browse.sh\n \n SCRIPT_PERL += git-add--interactive.perl\n+SCRIPT_PERL += git-difftool.perl\n SCRIPT_PERL += git-archimport.perl\n SCRIPT_PERL += git-cvsexportcommit.perl\n SCRIPT_PERL += git-cvsimport.perl\ndiff --git a/command-list.txt b/command-list.txt\nindex 3583a33..fb03a2e 100644\n--- a/command-list.txt\n+++ b/command-list.txt\n@@ -33,6 +33,7 @@ git-diff                                mainporcelain common\n git-diff-files                          plumbinginterrogators\n git-diff-index                          plumbinginterrogators\n git-diff-tree                           plumbinginterrogators\n+git-difftool                            ancillaryinterrogators\n git-fast-export\t\t\t\tancillarymanipulators\n git-fast-import\t\t\t\tancillarymanipulators\n git-fetch                               mainporcelain common\ndiff --git a/contrib/difftool/git-difftool-helper b/git-difftool--helper.sh\nsimilarity index 98%\nrename from contrib/difftool/git-difftool-helper\nrename to git-difftool--helper.sh\nindex 4b0daec..fc61416 100755\n--- a/contrib/difftool/git-difftool-helper\n+++ b/git-difftool--helper.sh\n@@ -1,5 +1,5 @@\n #!/bin/sh\n-# git-difftool-helper is a GIT_EXTERNAL_DIFF-compatible diff tool launcher.\n+# git-difftool--helper is a GIT_EXTERNAL_DIFF-compatible diff tool launcher.\n # This script is typically launched by using the 'git difftool'\n # convenience command.\n #\ndiff --git a/contrib/difftool/git-difftool b/git-difftool.perl\nsimilarity index 92%\nrename from contrib/difftool/git-difftool\nrename to git-difftool.perl\nindex 8c160e5..8857ac8 100755\n--- a/contrib/difftool/git-difftool\n+++ b/git-difftool.perl\n@@ -2,9 +2,9 @@\n # Copyright (c) 2009 David Aguilar\n #\n # This is a wrapper around the GIT_EXTERNAL_DIFF-compatible\n-# git-difftool-helper script.  This script exports\n+# git-difftool--helper script.  This script exports\n # GIT_EXTERNAL_DIFF and GIT_PAGER for use by git, and\n-# GIT_DIFFTOOL_NO_PROMPT and GIT_DIFF_TOOL for use by git-difftool-helper.\n+# GIT_DIFFTOOL_NO_PROMPT and GIT_DIFF_TOOL for use by git-difftool--helper.\n # Any arguments that are unknown to this script are forwarded to 'git diff'.\n \n use strict;\n@@ -27,7 +27,7 @@ sub setup_environment\n {\n \t$ENV{PATH} = \"$DIR:$ENV{PATH}\";\n \t$ENV{GIT_PAGER} = '';\n-\t$ENV{GIT_EXTERNAL_DIFF} = 'git-difftool-helper';\n+\t$ENV{GIT_EXTERNAL_DIFF} = 'git-difftool--helper';\n }\n \n sub exe\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110544","messageId":"1239006689-14695-11-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-10-git-send-email-davvid@gmail.com","subject":"[PATCH 10/14] difftool: add various git-difftool tests","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:25Z","receivedAt":"2009-04-06T08:31:25Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"t7800-difftool.sh tests the various command-line flags,\ngit-config variables, and environment settings supported by\ngit-difftool.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n t/t7800-difftool.sh |  147 +++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 147 insertions(+), 0 deletions(-)\n create mode 100755 t/t7800-difftool.sh\n\ndiff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh\nnew file mode 100755\nindex 0000000..85946d9\n--- /dev/null\n+++ b/t/t7800-difftool.sh\n@@ -0,0 +1,147 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2009 David Aguilar\n+#\n+\n+test_description='git-difftool\n+\n+Testing basic diff tool invocation\n+'\n+\n+. ./test-lib.sh\n+\n+remove_config_vars()\n+{\n+\t# Unset all config variables used by git-difftool\n+\tgit config --unset diff.tool\n+\tgit config --unset difftool.test-tool.cmd\n+\tgit config --unset merge.tool\n+\tgit config --unset mergetool.test-tool.cmd\n+\treturn 0\n+}\n+\n+restore_test_defaults()\n+{\n+\t# Restores the test defaults used by several tests\n+\tremove_config_vars\n+\tunset GIT_DIFF_TOOL\n+\tunset GIT_MERGE_TOOL\n+\tunset GIT_DIFFTOOL_NO_PROMPT\n+\tgit config diff.tool test-tool &&\n+\tgit config difftool.test-tool.cmd 'cat $LOCAL'\n+}\n+\n+# Create a file on master and change it on branch\n+test_expect_success 'setup' '\n+\techo master >file &&\n+\tgit add file &&\n+\tgit commit -m \"added file\" &&\n+\n+\tgit checkout -b branch master &&\n+\techo branch >file &&\n+\tgit commit -a -m \"branch changed file\" &&\n+\tgit checkout master\n+'\n+\n+# Configure a custom difftool.<tool>.cmd and use it\n+test_expect_success 'custom commands' '\n+\trestore_test_defaults &&\n+\tgit config difftool.test-tool.cmd \"cat \\$REMOTE\" &&\n+\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"master\" &&\n+\n+\trestore_test_defaults &&\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\"\n+'\n+\n+# Ensures that git-difftool ignores bogus --tool values\n+test_expect_success 'difftool ignores bad --tool values' '\n+\tdiff=$(git difftool --no-prompt --tool=bogus-tool branch)\n+\ttest \"$?\" = 1 &&\n+\ttest \"$diff\" = \"\"\n+'\n+\n+# Specify the diff tool using $GIT_DIFF_TOOL\n+test_expect_success 'GIT_DIFF_TOOL variable' '\n+\tgit config --unset diff.tool\n+\tGIT_DIFF_TOOL=test-tool &&\n+\texport GIT_DIFF_TOOL &&\n+\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults\n+'\n+\n+# Test the $GIT_*_TOOL variables and ensure\n+# that $GIT_DIFF_TOOL always wins unless --tool is specified\n+test_expect_success 'GIT_DIFF_TOOL overrides' '\n+\tgit config diff.tool bogus-tool &&\n+\tgit config merge.tool bogus-tool &&\n+\n+\tGIT_MERGE_TOOL=test-tool &&\n+\texport GIT_MERGE_TOOL &&\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\tunset GIT_MERGE_TOOL &&\n+\n+\tGIT_MERGE_TOOL=bogus-tool &&\n+\tGIT_DIFF_TOOL=test-tool &&\n+\texport GIT_MERGE_TOOL &&\n+\texport GIT_DIFF_TOOL &&\n+\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\tGIT_DIFF_TOOL=bogus-tool &&\n+\texport GIT_DIFF_TOOL &&\n+\n+\tdiff=$(git difftool --no-prompt --tool=test-tool branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults\n+'\n+\n+# Test that we don't have to pass --no-prompt to difftool\n+# when $GIT_DIFFTOOL_NO_PROMPT is true\n+test_expect_success 'GIT_DIFFTOOL_NO_PROMPT variable' '\n+\tGIT_DIFFTOOL_NO_PROMPT=true &&\n+\texport GIT_DIFFTOOL_NO_PROMPT &&\n+\n+\tdiff=$(git difftool branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults\n+'\n+\n+# git-difftool falls back to git-mergetool config variables\n+# so test that behavior here\n+test_expect_success 'difftool + mergetool config variables' '\n+\tremove_config_vars\n+\tgit config merge.tool test-tool &&\n+\tgit config mergetool.test-tool.cmd \"cat \\$LOCAL\" &&\n+\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\t# set merge.tool to something bogus, diff.tool to test-tool\n+\tgit config merge.tool bogus-tool &&\n+\tgit config diff.tool test-tool &&\n+\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults\n+'\n+\n+test_expect_success 'difftool.<tool>.path' '\n+\tgit config difftool.tkdiff.path echo &&\n+\tdiff=$(git difftool --no-prompt -t tkdiff branch) &&\n+\tgit config --unset difftool.tkdiff.path &&\n+\tlines=$(echo \"$diff\" | grep file | wc -l) &&\n+\ttest \"$lines\" = 1\n+'\n+\n+test_done\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110542","messageId":"1239006689-14695-12-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-11-git-send-email-davvid@gmail.com","subject":"[PATCH 11/14] difftool: add support for a difftool.prompt config variable","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:26Z","receivedAt":"2009-04-06T08:31:26Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"difftool now supports difftool.prompt so that users do not have to\npass --no-prompt or hit enter each time a diff tool is launched.\nThe --prompt flag overrides the configuration variable.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n Documentation/config.txt       |    3 ++\n Documentation/git-difftool.txt |   10 +++++-\n git-difftool--helper.sh        |   10 +++++-\n git-difftool.perl              |   15 +++++++--\n t/t7800-difftool.sh            |   64 ++++++++++++++++++++++++++++++++++++++++\n 5 files changed, 96 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 185a9ef..79c8b66 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -684,6 +684,9 @@ difftool.<tool>.cmd::\n \tis set to the name of the temporary file containing the contents\n \tof the diff post-image.\n \n+difftool.prompt::\n+\tPrompt before each invocation of the diff tool.\n+\n diff.wordRegex::\n \tA POSIX Extended Regular Expression used to determine what is a \"word\"\n \twhen performing word-by-word difference calculations.  Character\ndiff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt\nindex a2fa474..d2d762c 100644\n--- a/Documentation/git-difftool.txt\n+++ b/Documentation/git-difftool.txt\n@@ -7,7 +7,7 @@ git-difftool - Show changes using common diff tools\n \n SYNOPSIS\n --------\n-'git difftool' [-t|--tool=<tool>] [-y|--no-prompt] [<'git diff' options>]\n+'git difftool' [-t|--tool=<tool>] [-y|--no-prompt|--prompt] [<'git diff' options>]\n \n DESCRIPTION\n -----------\n@@ -21,6 +21,11 @@ OPTIONS\n --no-prompt::\n \tDo not prompt before launching a diff tool.\n \n+--prompt::\n+\tPrompt before each invocation of the diff tool.\n+\tThis is the default behaviour; the option is provided to\n+\toverride any configuration settings.\n+\n -t <tool>::\n --tool=<tool>::\n \tUse the diff tool specified by <tool>.\n@@ -72,6 +77,9 @@ difftool.<tool>.cmd::\n +\n See the `--tool=<tool>` option above for more details.\n \n+difftool.prompt::\n+\tPrompt before each invocation of the diff tool.\n+\n SEE ALSO\n --------\n linkgit:git-diff[1]::\ndiff --git a/git-difftool--helper.sh b/git-difftool--helper.sh\nindex fc61416..f3c27d8 100755\n--- a/git-difftool--helper.sh\n+++ b/git-difftool--helper.sh\n@@ -5,9 +5,15 @@\n #\n # Copyright (c) 2009 David Aguilar\n \n-# Set GIT_DIFFTOOL_NO_PROMPT to bypass the per-file prompt.\n+# difftool.prompt controls the default prompt/no-prompt behavior\n+# and is overridden with $GIT_DIFFTOOL*_PROMPT.\n should_prompt () {\n-\ttest -z \"$GIT_DIFFTOOL_NO_PROMPT\"\n+\tprompt=$(git config --bool difftool.prompt || echo true)\n+\tif test \"$prompt\" = true; then\n+\t\ttest -z \"$GIT_DIFFTOOL_NO_PROMPT\"\n+\telse\n+\t\ttest -n \"$GIT_DIFFTOOL_PROMPT\"\n+\tfi\n }\n \n # This function prepares temporary files and launches the appropriate\ndiff --git a/git-difftool.perl b/git-difftool.perl\nindex 8857ac8..948ff7f 100755\n--- a/git-difftool.perl\n+++ b/git-difftool.perl\n@@ -2,9 +2,12 @@\n # Copyright (c) 2009 David Aguilar\n #\n # This is a wrapper around the GIT_EXTERNAL_DIFF-compatible\n-# git-difftool--helper script.  This script exports\n-# GIT_EXTERNAL_DIFF and GIT_PAGER for use by git, and\n-# GIT_DIFFTOOL_NO_PROMPT and GIT_DIFF_TOOL for use by git-difftool--helper.\n+# git-difftool--helper script.\n+#\n+# This script exports GIT_EXTERNAL_DIFF and GIT_PAGER for use by git.\n+# GIT_DIFFTOOL_NO_PROMPT, GIT_DIFFTOOL_PROMPT, and GIT_DIFF_TOOL\n+# are exported for use by git-difftool--helper.\n+#\n # Any arguments that are unknown to this script are forwarded to 'git diff'.\n \n use strict;\n@@ -62,6 +65,12 @@ sub generate_command\n \t\t}\n \t\tif ($arg eq '-y' || $arg eq '--no-prompt') {\n \t\t\t$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';\n+\t\t\tdelete $ENV{GIT_DIFFTOOL_PROMPT};\n+\t\t\tnext;\n+\t\t}\n+\t\tif ($arg eq '--prompt') {\n+\t\t\t$ENV{GIT_DIFFTOOL_PROMPT} = 'true';\n+\t\t\tdelete $ENV{GIT_DIFFTOOL_NO_PROMPT};\n \t\t\tnext;\n \t\t}\n \t\tif ($arg eq '-h' || $arg eq '--help') {\ndiff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh\nindex 85946d9..0b263ea 100755\n--- a/t/t7800-difftool.sh\n+++ b/t/t7800-difftool.sh\n@@ -15,6 +15,7 @@ remove_config_vars()\n \t# Unset all config variables used by git-difftool\n \tgit config --unset diff.tool\n \tgit config --unset difftool.test-tool.cmd\n+\tgit config --unset difftool.prompt\n \tgit config --unset merge.tool\n \tgit config --unset mergetool.test-tool.cmd\n \treturn 0\n@@ -26,11 +27,18 @@ restore_test_defaults()\n \tremove_config_vars\n \tunset GIT_DIFF_TOOL\n \tunset GIT_MERGE_TOOL\n+\tunset GIT_DIFFTOOL_PROMPT\n \tunset GIT_DIFFTOOL_NO_PROMPT\n \tgit config diff.tool test-tool &&\n \tgit config difftool.test-tool.cmd 'cat $LOCAL'\n }\n \n+prompt_given()\n+{\n+\tprompt=\"$1\"\n+\ttest \"$prompt\" = \"Hit return to launch 'test-tool': branch\"\n+}\n+\n # Create a file on master and change it on branch\n test_expect_success 'setup' '\n \techo master >file &&\n@@ -116,6 +124,62 @@ test_expect_success 'GIT_DIFFTOOL_NO_PROMPT variable' '\n \trestore_test_defaults\n '\n \n+# git-difftool supports the difftool.prompt variable.\n+# Test that GIT_DIFFTOOL_PROMPT can override difftool.prompt = false\n+test_expect_success 'GIT_DIFFTOOL_PROMPT variable' '\n+\tgit config difftool.prompt false &&\n+\tGIT_DIFFTOOL_PROMPT=true &&\n+\texport GIT_DIFFTOOL_PROMPT &&\n+\n+\tprompt=$(echo | git difftool --prompt branch | tail -1) &&\n+\tprompt_given \"$prompt\" &&\n+\n+\trestore_test_defaults\n+'\n+\n+# Test that we don't have to pass --no-prompt when difftool.prompt is false\n+test_expect_success 'difftool.prompt config variable is false' '\n+\tgit config difftool.prompt false &&\n+\n+\tdiff=$(git difftool branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults\n+'\n+\n+# Test that the -y flag can override difftool.prompt = true\n+test_expect_success 'difftool.prompt can overridden with -y' '\n+\tgit config difftool.prompt true &&\n+\n+\tdiff=$(git difftool -y branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults\n+'\n+\n+# Test that the --prompt flag can override difftool.prompt = false\n+test_expect_success 'difftool.prompt can overridden with --prompt' '\n+\tgit config difftool.prompt false &&\n+\n+\tprompt=$(echo | git difftool --prompt branch | tail -1) &&\n+\tprompt_given \"$prompt\" &&\n+\n+\trestore_test_defaults\n+'\n+\n+# Test that the last flag passed on the command-line wins\n+test_expect_success 'difftool last flag wins' '\n+\tdiff=$(git difftool --prompt --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults &&\n+\n+\tprompt=$(echo | git difftool --no-prompt --prompt branch | tail -1) &&\n+\tprompt_given \"$prompt\" &&\n+\n+\trestore_test_defaults\n+'\n+\n # git-difftool falls back to git-mergetool config variables\n # so test that behavior here\n test_expect_success 'difftool + mergetool config variables' '\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110543","messageId":"1239006689-14695-13-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-12-git-send-email-davvid@gmail.com","subject":"[PATCH 12/14] bash completion: add git-difftool","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:27Z","receivedAt":"2009-04-06T08:31:27Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"This adds completion for difftool's --tool flag.\nThe known diff tool names were also consolidated into\na single variable.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n contrib/completion/git-completion.bash |   27 ++++++++++++++++++++++-----\n 1 files changed, 22 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 4fcd77a..551e33e 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -909,6 +909,26 @@ _git_diff ()\n \t__git_complete_file\n }\n \n+__git_mergetools_common=\"diffuse ecmerge emerge kdiff3 meld opendiff\n+\t\t\ttkdiff vimdiff gvimdiff xxdiff\n+\"\n+\n+_git_difftool ()\n+{\n+\tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n+\tcase \"$cur\" in\n+\t--tool=*)\n+\t\t__gitcomp \"$__git_mergetools_common kompare\" \"\" \"${cur##--tool=}\"\n+\t\treturn\n+\t\t;;\n+\t--*)\n+\t\t__gitcomp \"--tool=\"\n+\t\treturn\n+\t\t;;\n+\tesac\n+\tCOMPREPLY=()\n+}\n+\n __git_fetch_options=\"\n \t--quiet --verbose --append --upload-pack --force --keep --depth=\n \t--tags --no-tags\n@@ -1171,11 +1191,7 @@ _git_mergetool ()\n \tlocal cur=\"${COMP_WORDS[COMP_CWORD]}\"\n \tcase \"$cur\" in\n \t--tool=*)\n-\t\t__gitcomp \"\n-\t\t\tkdiff3 tkdiff meld xxdiff emerge\n-\t\t\tvimdiff gvimdiff ecmerge diffuse\n-\t\t\topendiff\n-\t\t\t\" \"\" \"${cur##--tool=}\"\n+\t\t__gitcomp \"$__git_mergetools_common tortoisemerge\" \"\" \"${cur##--tool=}\"\n \t\treturn\n \t\t;;\n \t--*)\n@@ -1900,6 +1916,7 @@ _git ()\n \tconfig)      _git_config ;;\n \tdescribe)    _git_describe ;;\n \tdiff)        _git_diff ;;\n+\tdifftool)    _git_difftool ;;\n \tfetch)       _git_fetch ;;\n \tformat-patch) _git_format_patch ;;\n \tfsck)        _git_fsck ;;\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110538","messageId":"1239006689-14695-14-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-13-git-send-email-davvid@gmail.com","subject":"[PATCH 13/14] mergetool: use $( ... ) instead of `backticks`","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:28Z","receivedAt":"2009-04-06T08:31:28Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"This makes mergetool consistent with Documentation/CodingGuidelines.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-mergetool.sh |   16 ++++++++--------\n 1 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex b4d2432..cceebb7 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -137,7 +137,7 @@ checkout_staged_file () {\n merge_file () {\n     MERGED=\"$1\"\n \n-    f=`git ls-files -u -- \"$MERGED\"`\n+    f=$(git ls-files -u -- \"$MERGED\")\n     if test -z \"$f\" ; then\n \tif test ! -f \"$MERGED\" ; then\n \t    echo \"$MERGED: file not found\"\n@@ -156,9 +156,9 @@ merge_file () {\n     mv -- \"$MERGED\" \"$BACKUP\"\n     cp -- \"$BACKUP\" \"$MERGED\"\n \n-    base_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==1) print $1;}'`\n-    local_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==2) print $1;}'`\n-    remote_mode=`git ls-files -u -- \"$MERGED\" | awk '{if ($3==3) print $1;}'`\n+    base_mode=$(git ls-files -u -- \"$MERGED\" | awk '{if ($3==1) print $1;}')\n+    local_mode=$(git ls-files -u -- \"$MERGED\" | awk '{if ($3==2) print $1;}')\n+    remote_mode=$(git ls-files -u -- \"$MERGED\" | awk '{if ($3==3) print $1;}')\n \n     base_present   && checkout_staged_file 1 \"$MERGED\" \"$BASE\"\n     local_present  && checkout_staged_file 2 \"$MERGED\" \"$LOCAL\"\n@@ -318,7 +318,7 @@ do\n \t-t|--tool*)\n \t    case \"$#,$1\" in\n \t\t*,*=*)\n-\t\t    merge_tool=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'`\n+\t\t    merge_tool=$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)')\n \t\t    ;;\n \t\t1,*)\n \t\t    usage ;;\n@@ -366,7 +366,7 @@ valid_tool() {\n }\n \n init_merge_tool_path() {\n-\tmerge_tool_path=`git config mergetool.$1.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\tvimdiff)\n@@ -403,7 +403,7 @@ prompt_after_failed_merge() {\n }\n \n if test -z \"$merge_tool\"; then\n-    merge_tool=`git config merge.tool`\n+    merge_tool=$(git config merge.tool)\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@@ -463,7 +463,7 @@ last_status=0\n rollup_status=0\n \n if test $# -eq 0 ; then\n-    files=`git ls-files -u | sed -e 's/^[^\t]*\t//' | sort -u`\n+    files=$(git ls-files -u | sed -e 's/^[^\t]*\t//' | sort -u)\n     if test -z \"$files\" ; then\n \techo \"No files need merging\"\n \texit 0\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110541","messageId":"1239006689-14695-15-git-send-email-davvid@gmail.com","threadId":"18744","inReplyTo":"1239006689-14695-14-git-send-email-davvid@gmail.com","subject":"[PATCH 14/14] difftool/mergetool: refactor commands to use git-mergetool--lib","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-04-06T08:31:29Z","receivedAt":"2009-04-06T08:31:29Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"This consolidates the common functionality from git-mergetool and\ngit-difftool--helper into a single git-mergetool--lib scriptlet.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n .gitignore                           |    1 +\n Documentation/git-mergetool--lib.txt |   56 ++++++\n Makefile                             |    1 +\n git-difftool--helper.sh              |  186 +-----------------\n git-mergetool--lib.sh                |  346 ++++++++++++++++++++++++++++++++++\n git-mergetool.sh                     |  224 ++---------------------\n 6 files changed, 426 insertions(+), 388 deletions(-)\n create mode 100644 Documentation/git-mergetool--lib.txt\n create mode 100644 git-mergetool--lib.sh\n\ndiff --git a/.gitignore b/.gitignore\nindex a36da9d..757c7f0 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -80,6 +80,7 @@ git-merge-recursive\n git-merge-resolve\n git-merge-subtree\n git-mergetool\n+git-mergetool--lib\n git-mktag\n git-mktree\n git-name-rev\ndiff --git a/Documentation/git-mergetool--lib.txt b/Documentation/git-mergetool--lib.txt\nnew file mode 100644\nindex 0000000..3d57031\n--- /dev/null\n+++ b/Documentation/git-mergetool--lib.txt\n@@ -0,0 +1,56 @@\n+git-mergetool--lib(1)\n+=====================\n+\n+NAME\n+----\n+git-mergetool--lib - Common git merge tool shell scriptlets\n+\n+SYNOPSIS\n+--------\n+'. \"$(git --exec-path)/git-mergetool--lib\"'\n+\n+DESCRIPTION\n+-----------\n+\n+This is not a command the end user would want to run.  Ever.\n+This documentation is meant for people who are studying the\n+Porcelain-ish scripts and/or are writing new ones.\n+\n+The 'git-mergetool--lib' scriptlet is designed to be sourced (using\n+`.`) by other shell scripts to set up functions for working\n+with git merge tools.\n+\n+Before sourcing it, your script should set up a few variables;\n+`TOOL_MODE` is used to define the operation mode for various\n+functions.  'diff' and 'merge' are valid values.\n+\n+FUNCTIONS\n+---------\n+get_merge_tool::\n+\treturns a merge tool\n+\n+get_merge_tool_cmd::\n+\treturns the custom command for a merge tool.\n+\n+get_merge_tool_path::\n+\treturns the custom path for a merge tool.\n+\n+run_merge_tool::\n+\tlaunches a merge tool given the tool name and a true/false\n+\tflag to indicate whether a merge base is present.\n+\t'$merge_tool', '$merge_tool_path', and for custom commands,\n+\t'$merge_tool_cmd', must be defined prior to calling\n+\trun_merge_tool.  Additionally, '$MERGED', '$LOCAL', '$REMOTE',\n+\tand '$BASE' must be defined for use by the merge tool.\n+\n+Author\n+------\n+Written by David Aguilar <davvid@gmail.com>\n+\n+Documentation\n+--------------\n+Documentation by David Aguilar and the git-list <git@vger.kernel.org>.\n+\n+GIT\n+---\n+Part of the linkgit:git[1] suite\ndiff --git a/Makefile b/Makefile\nindex a80055f..3e56274 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -284,6 +284,7 @@ SCRIPT_SH += git-merge-octopus.sh\n SCRIPT_SH += git-merge-one-file.sh\n SCRIPT_SH += git-merge-resolve.sh\n SCRIPT_SH += git-mergetool.sh\n+SCRIPT_SH += git-mergetool--lib.sh\n SCRIPT_SH += git-parse-remote.sh\n SCRIPT_SH += git-pull.sh\n SCRIPT_SH += git-quiltimport.sh\ndiff --git a/git-difftool--helper.sh b/git-difftool--helper.sh\nindex f3c27d8..b450036 100755\n--- a/git-difftool--helper.sh\n+++ b/git-difftool--helper.sh\n@@ -5,6 +5,10 @@\n #\n # Copyright (c) 2009 David Aguilar\n \n+# Load common functions from git-mergetool--lib\n+TOOL_MODE=diff\n+. git-mergetool--lib\n+\n # difftool.prompt controls the default prompt/no-prompt behavior\n # and is overridden with $GIT_DIFFTOOL*_PROMPT.\n should_prompt () {\n@@ -16,8 +20,7 @@ should_prompt () {\n \tfi\n }\n \n-# This function prepares temporary files and launches the appropriate\n-# merge tool.\n+# Sets up shell variables and runs a merge tool\n launch_merge_tool () {\n \t# Merged is the filename as it appears in the work tree\n \t# Local is the contents of a/filename\n@@ -37,187 +40,16 @@ launch_merge_tool () {\n \tfi\n \n \t# Run the appropriate merge tool command\n-\tcase \"$merge_tool\" in\n-\tkdiff3)\n-\t\tbasename=$(basename \"$MERGED\")\n-\t\t\"$merge_tool_path\" --auto \\\n-\t\t\t--L1 \"$basename (A)\" \\\n-\t\t\t--L2 \"$basename (B)\" \\\n-\t\t\t\"$LOCAL\" \"$REMOTE\" \\\n-\t\t\t> /dev/null 2>&1\n-\t\t;;\n-\n-\tkompare)\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\"\n-\t\t;;\n-\n-\ttkdiff)\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\"\n-\t\t;;\n-\n-\tmeld)\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\"\n-\t\t;;\n-\n-\tdiffuse)\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" | cat\n-\t\t;;\n-\n-\tvimdiff)\n-\t\t\"$merge_tool_path\" -d -c \"wincmd l\" \"$LOCAL\" \"$REMOTE\"\n-\t\t;;\n-\n-\tgvimdiff)\n-\t\t\"$merge_tool_path\" -d -c \"wincmd l\" -f \"$LOCAL\" \"$REMOTE\"\n-\t\t;;\n-\n-\txxdiff)\n-\t\t\"$merge_tool_path\" \\\n-\t\t\t-R 'Accel.Search: \"Ctrl+F\"' \\\n-\t\t\t-R 'Accel.SearchForward: \"Ctrl-G\"' \\\n-\t\t\t\"$LOCAL\" \"$REMOTE\"\n-\t\t;;\n-\n-\topendiff)\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" | cat\n-\t\t;;\n-\n-\tecmerge)\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n-\t\t\t--default --mode=merge2 --to=\"$MERGED\"\n-\t\t;;\n-\n-\temerge)\n-\t\t\"$merge_tool_path\" -f emerge-files-command \\\n-\t\t\t\"$LOCAL\" \"$REMOTE\" \"$(basename \"$MERGED\")\"\n-\t\t;;\n-\n-\t*)\n-\t\tif test -n \"$merge_tool_cmd\"; then\n-\t\t\t( eval $merge_tool_cmd )\n-\t\tfi\n-\t\t;;\n-\tesac\n-}\n-\n-# Verifies that (difftool|mergetool).<tool>.cmd exists\n-valid_custom_tool() {\n-\tmerge_tool_cmd=\"$(git config difftool.$1.cmd)\"\n-\ttest -z \"$merge_tool_cmd\" &&\n-\tmerge_tool_cmd=\"$(git config mergetool.$1.cmd)\"\n-\ttest -n \"$merge_tool_cmd\"\n-}\n-\n-# Verifies that the chosen merge tool is properly setup.\n-# Built-in merge tools are always valid.\n-valid_tool() {\n-\tcase \"$1\" in\n-\tkdiff3 | kompare | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)\n-\t\t;; # happy\n-\t*)\n-\t\tif ! valid_custom_tool \"$1\"\n-\t\tthen\n-\t\t\treturn 1\n-\t\tfi\n-\t\t;;\n-\tesac\n-}\n-\n-# Sets up the merge_tool_path variable.\n-# This handles the difftool.<tool>.path configuration.\n-# This also falls back to mergetool defaults.\n-init_merge_tool_path() {\n-\tmerge_tool_path=$(git config difftool.\"$1\".path)\n-\ttest -z \"$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\tvimdiff)\n-\t\t\tmerge_tool_path=vim\n-\t\t\t;;\n-\t\tgvimdiff)\n-\t\t\tmerge_tool_path=gvim\n-\t\t\t;;\n-\t\temerge)\n-\t\t\tmerge_tool_path=emacs\n-\t\t\t;;\n-\t\t*)\n-\t\t\tmerge_tool_path=\"$1\"\n-\t\t\t;;\n-\t\tesac\n-\tfi\n+\trun_merge_tool \"$merge_tool\"\n }\n \n # Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values\n test -n \"$GIT_MERGE_TOOL\" && merge_tool=\"$GIT_MERGE_TOOL\"\n test -n \"$GIT_DIFF_TOOL\" && merge_tool=\"$GIT_DIFF_TOOL\"\n \n-# If merge tool was not specified then use the diff.tool\n-# configuration variable.  If that's invalid then reset merge_tool.\n-# Fallback to merge.tool.\n-if test -z \"$merge_tool\"; then\n-\tmerge_tool=$(git config diff.tool)\n-\ttest -z \"$merge_tool\" &&\n-\tmerge_tool=$(git config merge.tool)\n-\tif test -n \"$merge_tool\" && ! valid_tool \"$merge_tool\"; then\n-\t\techo >&2 \"git config option diff.tool set to unknown tool: $merge_tool\"\n-\t\techo >&2 \"Resetting to default...\"\n-\t\tunset merge_tool\n-\tfi\n-fi\n-\n-# Try to guess an appropriate merge tool if no tool has been set.\n-if test -z \"$merge_tool\"; then\n-\t# We have a $DISPLAY so try some common UNIX merge tools\n-\tif test -n \"$DISPLAY\"; then\n-\t\t# If gnome then prefer meld, otherwise, prefer kdiff3 or kompare\n-\t\tif test -n \"$GNOME_DESKTOP_SESSION_ID\" ; then\n-\t\t\tmerge_tool_candidates=\"meld kdiff3 kompare tkdiff xxdiff gvimdiff diffuse\"\n-\t\telse\n-\t\t\tmerge_tool_candidates=\"kdiff3 kompare tkdiff xxdiff meld gvimdiff diffuse\"\n-\t\tfi\n-\tfi\n-\tif echo \"${VISUAL:-$EDITOR}\" | grep 'emacs' > /dev/null 2>&1; then\n-\t\t# $EDITOR is emacs so add emerge as a candidate\n-\t\tmerge_tool_candidates=\"$merge_tool_candidates emerge opendiff vimdiff\"\n-\telif echo \"${VISUAL:-$EDITOR}\" | grep 'vim' > /dev/null 2>&1; then\n-\t\t# $EDITOR is vim so add vimdiff as a candidate\n-\t\tmerge_tool_candidates=\"$merge_tool_candidates vimdiff opendiff emerge\"\n-\telse\n-\t\tmerge_tool_candidates=\"$merge_tool_candidates opendiff emerge vimdiff\"\n-\tfi\n-\techo \"merge tool candidates: $merge_tool_candidates\"\n-\n-\t# Loop over each candidate and stop when a valid merge tool is found.\n-\tfor i in $merge_tool_candidates\n-\tdo\n-\t\tinit_merge_tool_path $i\n-\t\tif type \"$merge_tool_path\" > /dev/null 2>&1; then\n-\t\t\tmerge_tool=$i\n-\t\t\tbreak\n-\t\tfi\n-\tdone\n-\n-\tif test -z \"$merge_tool\" ; then\n-\t\techo \"No known merge resolution program available.\"\n-\t\texit 1\n-\tfi\n-\n-else\n-\t# A merge tool has been set, so verify that it's valid.\n-\tif ! valid_tool \"$merge_tool\"; then\n-\t\techo >&2 \"Unknown merge tool $merge_tool\"\n-\t\texit 1\n-\tfi\n-\n-\tinit_merge_tool_path \"$merge_tool\"\n-\n-\tif test -z \"$merge_tool_cmd\" && ! type \"$merge_tool_path\" > /dev/null 2>&1; then\n-\t\techo \"The merge tool $merge_tool is not available as '$merge_tool_path'\"\n-\t\texit 1\n-\tfi\n-fi\n-\n+merge_tool=$(get_merge_tool \"$merge_tool\") || exit\n+merge_tool_cmd=\"$(get_merge_tool_cmd \"$merge_tool\")\"\n+merge_tool_path=\"$(get_merge_tool_path \"$merge_tool\")\" || exit\n \n # Launch the merge tool on each path provided by 'git diff'\n while test $# -gt 6\ndiff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\nnew file mode 100644\nindex 0000000..fa1d0ff\n--- /dev/null\n+++ b/git-mergetool--lib.sh\n@@ -0,0 +1,346 @@\n+# git-mergetool--lib is a library for common merge tool functions\n+diff_mode() {\n+\ttest $TOOL_MODE = \"diff\"\n+}\n+\n+merge_mode() {\n+\ttest $TOOL_MODE = \"merge\"\n+}\n+\n+translate_merge_tool_path () {\n+\tif test -n \"$2\"; then\n+\t\techo \"$2\"\n+\telse\n+\t\tcase \"$1\" in\n+\t\tvimdiff)\n+\t\t\tpath=vim\n+\t\t\t;;\n+\t\tgvimdiff)\n+\t\t\tpath=gvim\n+\t\t\t;;\n+\t\temerge)\n+\t\t\tpath=emacs\n+\t\t\t;;\n+\t\t*)\n+\t\t\tpath=\"$1\"\n+\t\t\t;;\n+\t\tesac\n+\t\techo \"$path\"\n+\tfi\n+}\n+\n+check_unchanged () {\n+\tif merge_mode; then\n+\t\tif test \"$MERGED\" -nt \"$BACKUP\"; then\n+\t\t\tstatus=0\n+\t\telse\n+\t\t\twhile true; do\n+\t\t\t\techo \"$MERGED seems unchanged.\"\n+\t\t\t\tprintf \"Was the merge successful? [y/n] \"\n+\t\t\t\tread answer < /dev/tty\n+\t\t\t\tcase \"$answer\" in\n+\t\t\t\ty*|Y*) status=0; break ;;\n+\t\t\t\tn*|N*) status=1; break ;;\n+\t\t\t\tesac\n+\t\t\tdone\n+\t\tfi\n+\telse\n+\t\tstatus=0\n+\tfi\n+\treturn $status\n+}\n+\n+valid_tool () {\n+\tcase \"$1\" in\n+\tkdiff3 | tkdiff | xxdiff | meld | opendiff | \\\n+\temerge | vimdiff | gvimdiff | ecmerge | diffuse)\n+\t\treturn 0\n+\t\t;; # happy\n+\tesac\n+\tif merge_mode && test \"$1\" = tortoisemerge; then\n+\t\treturn 0\n+\tfi\n+\tif diff_mode && test \"$1\" = kompare; then\n+\t\treturn 0\n+\tfi\n+\ttest -n \"$(get_merge_tool_cmd \"$1\")\"\n+}\n+\n+get_merge_tool_cmd () {\n+\tdiff_mode &&\n+\tcustom_cmd=\"$(git config difftool.$1.cmd)\"\n+\ttest -z \"$custom_cmd\" &&\n+\tcustom_cmd=\"$(git config mergetool.$1.cmd)\"\n+\ttest -n \"$custom_cmd\" &&\n+\techo \"$custom_cmd\"\n+}\n+\n+run_merge_tool () {\n+\tbase_present=\"$2\"\n+\tif diff_mode; then\n+\t\tbase_present=\"false\"\n+\tfi\n+\tif test -z \"$base_present\"; then\n+\t\tbase_present=\"true\"\n+\tfi\n+\n+\tcase \"$1\" in\n+\tkdiff3)\n+\t\tif $base_present; then\n+\t\t\t(\"$merge_tool_path\" --auto \\\n+\t\t\t --L1 \"$MERGED (Base)\" --L2 \"$MERGED (Local)\" --L3 \"$MERGED (Remote)\" \\\n+\t\t\t -o \"$MERGED\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n+\t\telse\n+\t\t\tif merge_mode; then\n+\t\t\t\t(\"$merge_tool_path\" --auto \\\n+\t\t\t\t --L1 \"$MERGED (Local)\" \\\n+\t\t\t\t --L2 \"$MERGED (Remote)\" \\\n+\t\t\t\t -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t> /dev/null 2>&1)\n+\t\t\telse\n+\t\t\t\t(\"$merge_tool_path\" --auto \\\n+\t\t\t\t --L1 \"$MERGED (A)\" \\\n+\t\t\t\t --L2 \"$MERGED (B)\" \\\n+\t\t\t\t \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t> /dev/null 2>&1)\n+\t\t\tfi\n+\t\tfi\n+\t\tstatus=$?\n+\t\t;;\n+\tkompare)\n+\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\"\n+\t\tstatus=$?\n+\t\t;;\n+\ttkdiff)\n+\t\tif $base_present; then\n+\t\t\t\"$merge_tool_path\" -a \"$BASE\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n+\t\telse\n+\t\t\tif merge_mode; then\n+\t\t\t\t\"$merge_tool_path\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n+\t\t\telse\n+\t\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\"\n+\t\t\tfi\n+\t\tfi\n+\t\tstatus=$?\n+\t\t;;\n+\tmeld)\n+\t\tif merge_mode; then\n+\t\t\ttouch \"$BACKUP\"\n+\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\telse\n+\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\"\n+\t\tfi\n+\t\tcheck_unchanged\n+\t\t;;\n+\tdiffuse)\n+\t\tif merge_mode; then\n+\t\t\ttouch \"$BACKUP\"\n+\t\tfi\n+\t\tif $base_present; then\n+\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\" \"$BASE\" | cat\n+\t\telse\n+\t\t\tif merge_mode; then\n+\t\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\" | cat\n+\t\t\telse\n+\t\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" | cat\n+\t\t\tfi\n+\t\tfi\n+\t\tcheck_unchanged\n+\t\t;;\n+\tvimdiff)\n+\t\tif merge_mode; then\n+\t\t\ttouch \"$BACKUP\"\n+\t\t\t\"$merge_tool_path\" -d -c \"wincmd l\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\tcheck_unchanged\n+\t\telse\n+\t\t\t\"$merge_tool_path\" -d -c \"wincmd l\" \"$LOCAL\" \"$REMOTE\"\n+\t\tfi\n+\t\t;;\n+\tgvimdiff)\n+\t\tif merge_mode; then\n+\t\t\ttouch \"$BACKUP\"\n+\t\t\t\"$merge_tool_path\" -d -c \"wincmd l\" -f \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n+\t\t\tcheck_unchanged\n+\t\telse\n+\t\t\t\"$merge_tool_path\" -d -c \"wincmd l\" -f \"$LOCAL\" \"$REMOTE\"\n+\t\tfi\n+\t\t;;\n+\txxdiff)\n+\t\tif merge_mode; then\n+\t\t\ttouch \"$BACKUP\"\n+\t\tfi\n+\t\tif $base_present; then\n+\t\t\t\"$merge_tool_path\" -X --show-merged-pane \\\n+\t\t\t    -R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n+\t\t\t    -R 'Accel.Search: \"Ctrl+F\"' \\\n+\t\t\t    -R 'Accel.SearchForward: \"Ctrl-G\"' \\\n+\t\t\t    --merged-file \"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n+\t\telse\n+\t\t\tif merge_mode; then\n+\t\t\t\t\"$merge_tool_path\" -X $extra \\\n+\t\t\t\t\t-R 'Accel.SaveAsMerged: \"Ctrl-S\"' \\\n+\t\t\t\t\t-R 'Accel.Search: \"Ctrl+F\"' \\\n+\t\t\t\t\t-R 'Accel.SearchForward: \"Ctrl-G\"' \\\n+\t\t\t\t\t--merged-file \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n+\t\t\telse\n+\t\t\t\t\"$merge_tool_path\" \\\n+\t\t\t\t\t-R 'Accel.Search: \"Ctrl+F\"' \\\n+\t\t\t\t\t-R 'Accel.SearchForward: \"Ctrl-G\"' \\\n+\t\t\t\t\t\"$LOCAL\" \"$REMOTE\"\n+\t\t\tfi\n+\t\tfi\n+\t\tcheck_unchanged\n+\t\t;;\n+\topendiff)\n+\t\tmerge_mode && touch \"$BACKUP\"\n+\t\tif $base_present; then\n+\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t-ancestor \"$BASE\" -merge \"$MERGED\" | cat\n+\t\telse\n+\t\t\tif merge_mode; then\n+\t\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t\t-merge \"$MERGED\" | cat\n+\t\t\telse\n+\t\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" | cat\n+\t\t\tfi\n+\t\tfi\n+\t\tcheck_unchanged\n+\t\t;;\n+\tecmerge)\n+\t\tmerge_mode && touch \"$BACKUP\"\n+\t\tif $base_present; then\n+\t\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t--default --mode=merge3 --to=\"$MERGED\"\n+\t\telse\n+\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" \\\n+\t\t\t\t--default --mode=merge2 --to=\"$MERGED\"\n+\t\tfi\n+\t\tcheck_unchanged\n+\t\t;;\n+\temerge)\n+\t\tif $base_present; then\n+\t\t\t\"$merge_tool_path\" -f emerge-files-with-ancestor-command \\\n+\t\t\t\t\"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$(basename \"$MERGED\")\"\n+\t\telse\n+\t\t\t\"$merge_tool_path\" -f emerge-files-command \\\n+\t\t\t\t\"$LOCAL\" \"$REMOTE\" \"$(basename \"$MERGED\")\"\n+\t\tfi\n+\t\tstatus=$?\n+\t\t;;\n+\ttortoisemerge)\n+\t\tif $base_present; then\n+\t\t\ttouch \"$BACKUP\"\n+\t\t\t\"$merge_tool_path\" -base:\"$BASE\" -mine:\"$LOCAL\" -theirs:\"$REMOTE\" -merged:\"$MERGED\"\n+\t\t\tcheck_unchanged\n+\t\telse\n+\t\t\techo \"TortoiseMerge cannot be used without a base\" 1>&2\n+\t\t\tstatus=1\n+\t\tfi\n+\t\t;;\n+\t*)\n+\t\tif test -n \"$merge_tool_cmd\"; then\n+\t\t\tif merge_mode &&\n+\t\t\ttest \"$merge_tool_trust_exit_code\" = \"false\"; then\n+\t\t\t\ttouch \"$BACKUP\"\n+\t\t\t\t( eval $merge_tool_cmd )\n+\t\t\t\tcheck_unchanged\n+\t\t\telse\n+\t\t\t\t( eval $merge_tool_cmd )\n+\t\t\t\tstatus=$?\n+\t\t\tfi\n+\t\tfi\n+\t\t;;\n+\tesac\n+\treturn $status\n+}\n+\n+guess_merge_tool () {\n+\tif diff_mode; then\n+\t\tkompare=\"kompare\"\n+\tfi\n+\tif test -n \"$DISPLAY\"; then\n+\t\tif test -n \"$GNOME_DESKTOP_SESSION_ID\" ; then\n+\t\t\ttools=\"meld kdiff3 $kompare tkdiff\"\n+\t\t\ttools=\"$tools xxdiff gvimdiff diffuse\"\n+\t\telse\n+\t\t\ttools=\"kdiff3 $kompare tkdiff xxdiff\"\n+\t\t\ttools=\"$tools meld gvimdiff diffuse\"\n+\t\tfi\n+\tfi\n+\tif echo \"${VISUAL:-$EDITOR}\" | grep emacs > /dev/null 2>&1; then\n+\t\t# $EDITOR is emacs so add emerge as a candidate\n+\t\ttools=\"$tools emerge opendiff vimdiff\"\n+\telif echo \"${VISUAL:-$EDITOR}\" | grep vim > /dev/null 2>&1; then\n+\t\t# $EDITOR is vim so add vimdiff as a candidate\n+\t\ttools=\"$tools vimdiff opendiff emerge\"\n+\telse\n+\t\ttools=\"$tools opendiff emerge vimdiff\"\n+\tfi\n+\techo >&2 \"merge tool candidates: $tools\"\n+\n+\t# Loop over each candidate and stop when a valid merge tool is found.\n+\tfor i in $tools\n+\tdo\n+\t\tmerge_tool_path=\"$(translate_merge_tool_path \"$i\")\"\n+\t\tif type \"$merge_tool_path\" > /dev/null 2>&1; then\n+\t\t\tmerge_tool=\"$i\"\n+\t\t\tbreak\n+\t\tfi\n+\tdone\n+\n+\tif test -z \"$merge_tool\" ; then\n+\t\techo >&2 \"No known merge resolution program available.\"\n+\t\treturn 1\n+\tfi\n+\techo \"$merge_tool\"\n+}\n+\n+get_configured_merge_tool () {\n+\t# Diff mode first tries diff.tool and falls back to merge.tool.\n+\t# Merge mode only checks merge.tool\n+\tif diff_mode; then\n+\t\ttool=$(git config diff.tool)\n+\tfi\n+\tif test -z \"$tool\"; then\n+\t\ttool=$(git config merge.tool)\n+\tfi\n+\tif test -n \"$merge_tool\" && ! valid_tool \"$merge_tool\"; then\n+\t\techo >&2 \"git config option $TOOL_MODE.tool set to unknown tool: $merge_tool\"\n+\t\techo >&2 \"Resetting to default...\"\n+\t\treturn 1\n+\tfi\n+\techo \"$tool\"\n+}\n+\n+get_merge_tool_path () {\n+\t# A merge tool has been set, so verify that it's valid.\n+\tif ! valid_tool \"$merge_tool\"; then\n+\t\techo >&2 \"Unknown merge tool $merge_tool\"\n+\t\texit 1\n+\tfi\n+\tif diff_mode; then\n+\t\tmerge_tool_path=$(git config difftool.\"$merge_tool\".path)\n+\tfi\n+\tif test -z \"$merge_tool_path\"; then\n+\t\tmerge_tool_path=$(git config mergetool.\"$merge_tool\".path)\n+\tfi\n+\tmerge_tool_path=\"$(translate_merge_tool_path \"$merge_tool\" \"$merge_tool_path\")\"\n+\tif test -z \"$merge_tool_cmd\" && ! type \"$merge_tool_path\" > /dev/null 2>&1; then\n+\t\techo >&2 \"The $TOOL_MODE tool $merge_tool is not available as '$merge_tool_path'\"\n+\t\texit 1\n+\tfi\n+\techo \"$merge_tool_path\"\n+}\n+\n+get_merge_tool () {\n+\tmerge_tool=\"$1\"\n+\t# Check if a merge tool has been configured\n+\tif test -z \"$merge_tool\"; then\n+\t\tmerge_tool=$(get_configured_merge_tool)\n+\tfi\n+\t# Try to guess an appropriate merge tool if no tool has been set.\n+\tif test -z \"$merge_tool\"; then\n+\t\tmerge_tool=$(guess_merge_tool) || exit\n+\tfi\n+\techo \"$merge_tool\"\n+}\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex cceebb7..efa31a2 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -11,7 +11,9 @@\n USAGE='[--tool=tool] [-y|--no-prompt|--prompt] [file to merge] ...'\n SUBDIRECTORY_OK=Yes\n OPTIONS_SPEC=\n+TOOL_MODE=merge\n . git-sh-setup\n+. git-mergetool--lib\n require_work_tree\n \n # Returns true if the mode reflects a symlink\n@@ -110,22 +112,6 @@ resolve_deleted_merge () {\n \tdone\n }\n \n-check_unchanged () {\n-    if test \"$MERGED\" -nt \"$BACKUP\" ; then\n-\tstatus=0;\n-    else\n-\twhile true; do\n-\t    echo \"$MERGED seems unchanged.\"\n-\t    printf \"Was the merge successful? [y/n] \"\n-\t    read answer < /dev/tty\n-\t    case \"$answer\" in\n-\t\ty*|Y*) status=0; break ;;\n-\t\tn*|N*) status=1; break ;;\n-\t    esac\n-\tdone\n-    fi\n-}\n-\n checkout_staged_file () {\n     tmpfile=$(expr \"$(git checkout-index --temp --stage=\"$1\" \"$2\")\" : '\\([^\t]*\\)\t')\n \n@@ -188,107 +174,11 @@ merge_file () {\n \tread ans\n     fi\n \n-    case \"$merge_tool\" in\n-\tkdiff3)\n-\t    if base_present ; then\n-\t\t(\"$merge_tool_path\" --auto --L1 \"$MERGED (Base)\" --L2 \"$MERGED (Local)\" --L3 \"$MERGED (Remote)\" \\\n-\t\t    -o \"$MERGED\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n-\t    else\n-\t\t(\"$merge_tool_path\" --auto --L1 \"$MERGED (Local)\" --L2 \"$MERGED (Remote)\" \\\n-\t\t    -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\" > /dev/null 2>&1)\n-\t    fi\n-\t    status=$?\n-\t    ;;\n-\ttkdiff)\n-\t    if base_present ; then\n-\t\t\"$merge_tool_path\" -a \"$BASE\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n-\t    else\n-\t\t\"$merge_tool_path\" -o \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n-\t    fi\n-\t    status=$?\n-\t    ;;\n-\tmeld)\n-\t    touch \"$BACKUP\"\n-\t    \"$merge_tool_path\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n-\t    check_unchanged\n-\t    ;;\n-\tvimdiff)\n-\t    touch \"$BACKUP\"\n-\t    \"$merge_tool_path\" -d -c \"wincmd l\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n-\t    check_unchanged\n-\t    ;;\n-\tgvimdiff)\n-\t    touch \"$BACKUP\"\n-\t    \"$merge_tool_path\" -d -c \"wincmd l\" -f \"$LOCAL\" \"$MERGED\" \"$REMOTE\"\n-\t    check_unchanged\n-\t    ;;\n-\txxdiff)\n-\t    touch \"$BACKUP\"\n-\t    if base_present ; then\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 \"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"\n-\t    else\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 \"$MERGED\" \"$LOCAL\" \"$REMOTE\"\n-\t    fi\n-\t    check_unchanged\n-\t    ;;\n-\topendiff)\n-\t    touch \"$BACKUP\"\n-\t    if base_present; then\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\" | cat\n-\t    else\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" -merge \"$MERGED\" | cat\n-\t    fi\n-\t    check_unchanged\n-\t    ;;\n-\tecmerge)\n-\t    touch \"$BACKUP\"\n-\t    if base_present; then\n-\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" --default --mode=merge3 --to=\"$MERGED\"\n-\t    else\n-\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\" --default --mode=merge2 --to=\"$MERGED\"\n-\t    fi\n-\t    check_unchanged\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 \"$MERGED\")\"\n-\t    else\n-\t\t\"$merge_tool_path\" -f emerge-files-command \"$LOCAL\" \"$REMOTE\" \"$(basename \"$MERGED\")\"\n-\t    fi\n-\t    status=$?\n-\t    ;;\n-\ttortoisemerge)\n-\t    if base_present ; then\n-\t\ttouch \"$BACKUP\"\n-\t\t\"$merge_tool_path\" -base:\"$BASE\" -mine:\"$LOCAL\" -theirs:\"$REMOTE\" -merged:\"$MERGED\"\n-\t\tcheck_unchanged\n-\t    else\n-\t\techo \"TortoiseMerge cannot be used without a base\" 1>&2\n-\t\tstatus=1\n-\t    fi\n-\t    ;;\n-\t*)\n-\t    if test -n \"$merge_tool_cmd\"; then\n-\t\tif test \"$merge_tool_trust_exit_code\" = \"false\"; then\n-\t\t    touch \"$BACKUP\"\n-\t\t    ( eval $merge_tool_cmd )\n-\t\t    check_unchanged\n-\t\telse\n-\t\t    ( eval $merge_tool_cmd )\n-\t\t    status=$?\n-\t\tfi\n-\t    fi\n-\t    ;;\n-    esac\n-    if test \"$status\" -ne 0; then\n+    present=false\n+    base_present &&\n+    present=true\n+\n+    if ! run_merge_tool \"$merge_tool\" \"$present\"; then\n \techo \"merge of $MERGED failed\" 1>&2\n \tmv -- \"$BACKUP\" \"$MERGED\"\n \n@@ -347,44 +237,6 @@ do\n     shift\n done\n \n-valid_custom_tool()\n-{\n-    merge_tool_cmd=\"$(git config mergetool.$1.cmd)\"\n-    test -n \"$merge_tool_cmd\"\n-}\n-\n-valid_tool() {\n-\tcase \"$1\" in\n-\t\tkdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge | tortoisemerge)\n-\t\t\t;; # happy\n-\t\t*)\n-\t\t\tif ! valid_custom_tool \"$1\"; then\n-\t\t\t\treturn 1\n-\t\t\tfi\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\tvimdiff)\n-\t\t\t\tmerge_tool_path=vim\n-\t\t\t\t;;\n-\t\t\tgvimdiff)\n-\t\t\t\tmerge_tool_path=gvim\n-\t\t\t\t;;\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 prompt_after_failed_merge() {\n     while true; do\n \tprintf \"Continue merging other unresolved paths (y/n) ? \"\n@@ -402,62 +254,12 @@ prompt_after_failed_merge() {\n     done\n }\n \n-if test -z \"$merge_tool\"; then\n-    merge_tool=$(git config merge.tool)\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-    fi\n-fi\n-\n-if test -z \"$merge_tool\" ; then\n-    if test -n \"$DISPLAY\"; then\n-        if test -n \"$GNOME_DESKTOP_SESSION_ID\" ; then\n-            merge_tool_candidates=\"meld kdiff3 tkdiff xxdiff tortoisemerge gvimdiff diffuse\"\n-        else\n-            merge_tool_candidates=\"kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse\"\n-        fi\n-    fi\n-    if echo \"${VISUAL:-$EDITOR}\" | grep 'emacs' > /dev/null 2>&1; then\n-        merge_tool_candidates=\"$merge_tool_candidates emerge opendiff vimdiff\"\n-    elif echo \"${VISUAL:-$EDITOR}\" | grep 'vim' > /dev/null 2>&1; then\n-        merge_tool_candidates=\"$merge_tool_candidates vimdiff opendiff emerge\"\n-    else\n-        merge_tool_candidates=\"$merge_tool_candidates opendiff emerge vimdiff\"\n-    fi\n-    echo \"merge tool candidates: $merge_tool_candidates\"\n-    for i in $merge_tool_candidates; do\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 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-    merge_keep_backup=\"$(git config --bool merge.keepBackup || echo true)\"\n-    merge_keep_temporaries=\"$(git config --bool mergetool.keepTemporaries || echo false)\"\n-\n-    if test -z \"$merge_tool_cmd\" && ! 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-\n-    if ! test -z \"$merge_tool_cmd\"; then\n-        merge_tool_trust_exit_code=\"$(git config --bool mergetool.$merge_tool.trustExitCode || echo false)\"\n-    fi\n-fi\n+merge_tool=$(get_merge_tool \"$merge_tool\") || exit\n+merge_tool_cmd=\"$(get_merge_tool_cmd \"$merge_tool\")\"\n+merge_tool_path=\"$(get_merge_tool_path \"$merge_tool\")\" || exit\n+merge_keep_backup=\"$(git config --bool merge.keepBackup || echo true)\"\n+merge_keep_temporaries=\"$(git config --bool mergetool.keepTemporaries || echo false)\"\n+merge_tool_trust_exit_code=\"$(git config --bool mergetool.\"$merge_tool\".trustExitCode || echo false)\"\n \n last_status=0\n rollup_status=0\n-- \n1.6.2.2.414.g81aa9\n"},{"id":"110637","messageId":"200904070017.25501.markus.heidelberg@web.de","threadId":"18744","inReplyTo":"1239006689-14695-8-git-send-email-davvid@gmail.com","subject":"Re: [PATCH 07/14] difftool: add a -y shortcut for --no-prompt","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-04-06T22:17:25Z","receivedAt":"2009-04-06T22:17:25Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"David Aguilar, 06.04.2009:\n> diff --git a/contrib/difftool/git-difftool.txt b/contrib/difftool/git-difftool.txt\n> index 2b7bc03..4dff529 100644\n> --- a/contrib/difftool/git-difftool.txt\n> +++ b/contrib/difftool/git-difftool.txt\n> @@ -3,35 +3,32 @@ git-difftool(1)\n>  \n>  NAME\n>  ----\n> -git-difftool - compare changes using common merge tools\n> +git-difftool - Show changes using common diff tools\n>  \n>  SYNOPSIS\n>  --------\n> -'git difftool' [--tool=<tool>] [--no-prompt] ['git diff' options]\n> +'git difftool' [-t|--tool=<tool>] [-y|--no-prompt] [<'git diff' options>]\n\n\"-t <tool>\" would be more correct than only \"-t\". But I'm not sure if it\nshould go in there, mergetool doesn't have it either. It's only the\nsynopsis, is there any \"official\" guideline on how much to include\nthere and whether to avoid different options with the same meaning?\n"},{"id":"110643","messageId":"200904070142.39026.markus.heidelberg@web.de","threadId":"18744","inReplyTo":"1239006689-14695-10-git-send-email-davvid@gmail.com","subject":"Re: [PATCH 09/14] difftool: move 'git-difftool' out of contrib","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-04-06T23:42:38Z","receivedAt":"2009-04-06T23:42:38Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"David Aguilar, 06.04.2009:\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> +diff.tool::\n> +\tControls which diff tool is used.  `diff.tool` overrides\n> +\t`merge.tool` when used by linkgit:git-difftool[1] and has\n> +\tthe same valid values as `merge.tool`.\n\n+kompare\n-tortoisemerge\n"}]}