From afcbc8e7ecb18a3ee542e808f02f5df7d56d5bdc Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Tue, 7 Apr 2009 01:21:20 -0700 Subject: difftool: move 'git-difftool' out of contrib This prepares 'git-difftool' and its documentation for mainstream use. 'git-difftool-helper' became 'git-difftool--helper' since users should not use it directly. 'git-difftool' was added to the list of commands as an ancillaryinterrogator. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 221 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100755 git-difftool--helper.sh (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh new file mode 100755 index 0000000000..fc61416acb --- /dev/null +++ b/git-difftool--helper.sh @@ -0,0 +1,221 @@ +#!/bin/sh +# git-difftool--helper is a GIT_EXTERNAL_DIFF-compatible diff tool launcher. +# This script is typically launched by using the 'git difftool' +# convenience command. +# +# Copyright (c) 2009 David Aguilar + +# Set GIT_DIFFTOOL_NO_PROMPT to bypass the per-file prompt. +should_prompt () { + test -z "$GIT_DIFFTOOL_NO_PROMPT" +} + +# This function prepares temporary files and launches the appropriate +# merge tool. +launch_merge_tool () { + # Merged is the filename as it appears in the work tree + # Local is the contents of a/filename + # Remote is the contents of b/filename + # Custom merge tool commands might use $BASE so we provide it + MERGED="$1" + LOCAL="$2" + REMOTE="$3" + BASE="$1" + + # $LOCAL and $REMOTE are temporary files so prompt + # the user with the real $MERGED name before launching $merge_tool. + if should_prompt; then + printf "\nViewing: '$MERGED'\n" + printf "Hit return to launch '%s': " "$merge_tool" + read ans + fi + + # Run the appropriate merge tool command + case "$merge_tool" in + kdiff3) + basename=$(basename "$MERGED") + "$merge_tool_path" --auto \ + --L1 "$basename (A)" \ + --L2 "$basename (B)" \ + "$LOCAL" "$REMOTE" \ + > /dev/null 2>&1 + ;; + + kompare) + "$merge_tool_path" "$LOCAL" "$REMOTE" + ;; + + tkdiff) + "$merge_tool_path" "$LOCAL" "$REMOTE" + ;; + + meld) + "$merge_tool_path" "$LOCAL" "$REMOTE" + ;; + + diffuse) + "$merge_tool_path" "$LOCAL" "$REMOTE" | cat + ;; + + vimdiff) + "$merge_tool_path" -d -c "wincmd l" "$LOCAL" "$REMOTE" + ;; + + gvimdiff) + "$merge_tool_path" -d -c "wincmd l" -f "$LOCAL" "$REMOTE" + ;; + + xxdiff) + "$merge_tool_path" \ + -R 'Accel.Search: "Ctrl+F"' \ + -R 'Accel.SearchForward: "Ctrl-G"' \ + "$LOCAL" "$REMOTE" + ;; + + opendiff) + "$merge_tool_path" "$LOCAL" "$REMOTE" | cat + ;; + + ecmerge) + "$merge_tool_path" "$LOCAL" "$REMOTE" \ + --default --mode=merge2 --to="$MERGED" + ;; + + emerge) + "$merge_tool_path" -f emerge-files-command \ + "$LOCAL" "$REMOTE" "$(basename "$MERGED")" + ;; + + *) + if test -n "$merge_tool_cmd"; then + ( eval $merge_tool_cmd ) + fi + ;; + esac +} + +# Verifies that (difftool|mergetool)..cmd exists +valid_custom_tool() { + merge_tool_cmd="$(git config difftool.$1.cmd)" + test -z "$merge_tool_cmd" && + merge_tool_cmd="$(git config mergetool.$1.cmd)" + test -n "$merge_tool_cmd" +} + +# Verifies that the chosen merge tool is properly setup. +# Built-in merge tools are always valid. +valid_tool() { + case "$1" in + kdiff3 | kompare | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge) + ;; # happy + *) + if ! valid_custom_tool "$1" + then + return 1 + fi + ;; + esac +} + +# Sets up the merge_tool_path variable. +# This handles the difftool..path configuration. +# This also falls back to mergetool defaults. +init_merge_tool_path() { + merge_tool_path=$(git config difftool."$1".path) + test -z "$merge_tool_path" && + merge_tool_path=$(git config mergetool."$1".path) + if test -z "$merge_tool_path"; then + case "$1" in + vimdiff) + merge_tool_path=vim + ;; + gvimdiff) + merge_tool_path=gvim + ;; + emerge) + merge_tool_path=emacs + ;; + *) + merge_tool_path="$1" + ;; + esac + fi +} + +# Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values +test -n "$GIT_MERGE_TOOL" && merge_tool="$GIT_MERGE_TOOL" +test -n "$GIT_DIFF_TOOL" && merge_tool="$GIT_DIFF_TOOL" + +# If merge tool was not specified then use the diff.tool +# configuration variable. If that's invalid then reset merge_tool. +# Fallback to merge.tool. +if test -z "$merge_tool"; then + merge_tool=$(git config diff.tool) + test -z "$merge_tool" && + merge_tool=$(git config merge.tool) + if test -n "$merge_tool" && ! valid_tool "$merge_tool"; then + echo >&2 "git config option diff.tool set to unknown tool: $merge_tool" + echo >&2 "Resetting to default..." + unset merge_tool + fi +fi + +# Try to guess an appropriate merge tool if no tool has been set. +if test -z "$merge_tool"; then + # We have a $DISPLAY so try some common UNIX merge tools + if test -n "$DISPLAY"; then + # If gnome then prefer meld, otherwise, prefer kdiff3 or kompare + if test -n "$GNOME_DESKTOP_SESSION_ID" ; then + merge_tool_candidates="meld kdiff3 kompare tkdiff xxdiff gvimdiff diffuse" + else + merge_tool_candidates="kdiff3 kompare tkdiff xxdiff meld gvimdiff diffuse" + fi + fi + if echo "${VISUAL:-$EDITOR}" | grep 'emacs' > /dev/null 2>&1; then + # $EDITOR is emacs so add emerge as a candidate + merge_tool_candidates="$merge_tool_candidates emerge opendiff vimdiff" + elif echo "${VISUAL:-$EDITOR}" | grep 'vim' > /dev/null 2>&1; then + # $EDITOR is vim so add vimdiff as a candidate + merge_tool_candidates="$merge_tool_candidates vimdiff opendiff emerge" + else + merge_tool_candidates="$merge_tool_candidates opendiff emerge vimdiff" + fi + echo "merge tool candidates: $merge_tool_candidates" + + # Loop over each candidate and stop when a valid merge tool is found. + for i in $merge_tool_candidates + do + init_merge_tool_path $i + if type "$merge_tool_path" > /dev/null 2>&1; then + merge_tool=$i + break + fi + done + + if test -z "$merge_tool" ; then + echo "No known merge resolution program available." + exit 1 + fi + +else + # A merge tool has been set, so verify that it's valid. + if ! valid_tool "$merge_tool"; then + echo >&2 "Unknown merge tool $merge_tool" + exit 1 + fi + + init_merge_tool_path "$merge_tool" + + if test -z "$merge_tool_cmd" && ! type "$merge_tool_path" > /dev/null 2>&1; then + echo "The merge tool $merge_tool is not available as '$merge_tool_path'" + exit 1 + fi +fi + + +# Launch the merge tool on each path provided by 'git diff' +while test $# -gt 6 +do + launch_merge_tool "$1" "$2" "$5" + shift 7 +done -- cgit v1.2.3 From a904392eaeee1629c0ac14dae8e579bb8497636a Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Tue, 7 Apr 2009 01:21:22 -0700 Subject: difftool: add support for a difftool.prompt config variable difftool now supports difftool.prompt so that users do not have to pass --no-prompt or hit enter each time a diff tool is launched. The --prompt flag overrides the configuration variable. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index fc61416acb..f3c27d86ad 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -5,9 +5,15 @@ # # Copyright (c) 2009 David Aguilar -# Set GIT_DIFFTOOL_NO_PROMPT to bypass the per-file prompt. +# difftool.prompt controls the default prompt/no-prompt behavior +# and is overridden with $GIT_DIFFTOOL*_PROMPT. should_prompt () { - test -z "$GIT_DIFFTOOL_NO_PROMPT" + prompt=$(git config --bool difftool.prompt || echo true) + if test "$prompt" = true; then + test -z "$GIT_DIFFTOOL_NO_PROMPT" + else + test -n "$GIT_DIFFTOOL_PROMPT" + fi } # This function prepares temporary files and launches the appropriate -- cgit v1.2.3 From 21d0ba7ebb0c6b6c6ad844f8a40fff8dd4c0b105 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Wed, 8 Apr 2009 00:17:20 -0700 Subject: difftool/mergetool: refactor commands to use git-mergetool--lib This consolidates the common functionality from git-mergetool and git-difftool--helper into a single git-mergetool--lib scriptlet. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 186 +++--------------------------------------------- 1 file changed, 9 insertions(+), 177 deletions(-) (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index f3c27d86ad..b4500368c3 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -5,6 +5,10 @@ # # Copyright (c) 2009 David Aguilar +# Load common functions from git-mergetool--lib +TOOL_MODE=diff +. git-mergetool--lib + # difftool.prompt controls the default prompt/no-prompt behavior # and is overridden with $GIT_DIFFTOOL*_PROMPT. should_prompt () { @@ -16,8 +20,7 @@ should_prompt () { fi } -# This function prepares temporary files and launches the appropriate -# merge tool. +# Sets up shell variables and runs a merge tool launch_merge_tool () { # Merged is the filename as it appears in the work tree # Local is the contents of a/filename @@ -37,187 +40,16 @@ launch_merge_tool () { fi # Run the appropriate merge tool command - case "$merge_tool" in - kdiff3) - basename=$(basename "$MERGED") - "$merge_tool_path" --auto \ - --L1 "$basename (A)" \ - --L2 "$basename (B)" \ - "$LOCAL" "$REMOTE" \ - > /dev/null 2>&1 - ;; - - kompare) - "$merge_tool_path" "$LOCAL" "$REMOTE" - ;; - - tkdiff) - "$merge_tool_path" "$LOCAL" "$REMOTE" - ;; - - meld) - "$merge_tool_path" "$LOCAL" "$REMOTE" - ;; - - diffuse) - "$merge_tool_path" "$LOCAL" "$REMOTE" | cat - ;; - - vimdiff) - "$merge_tool_path" -d -c "wincmd l" "$LOCAL" "$REMOTE" - ;; - - gvimdiff) - "$merge_tool_path" -d -c "wincmd l" -f "$LOCAL" "$REMOTE" - ;; - - xxdiff) - "$merge_tool_path" \ - -R 'Accel.Search: "Ctrl+F"' \ - -R 'Accel.SearchForward: "Ctrl-G"' \ - "$LOCAL" "$REMOTE" - ;; - - opendiff) - "$merge_tool_path" "$LOCAL" "$REMOTE" | cat - ;; - - ecmerge) - "$merge_tool_path" "$LOCAL" "$REMOTE" \ - --default --mode=merge2 --to="$MERGED" - ;; - - emerge) - "$merge_tool_path" -f emerge-files-command \ - "$LOCAL" "$REMOTE" "$(basename "$MERGED")" - ;; - - *) - if test -n "$merge_tool_cmd"; then - ( eval $merge_tool_cmd ) - fi - ;; - esac -} - -# Verifies that (difftool|mergetool)..cmd exists -valid_custom_tool() { - merge_tool_cmd="$(git config difftool.$1.cmd)" - test -z "$merge_tool_cmd" && - merge_tool_cmd="$(git config mergetool.$1.cmd)" - test -n "$merge_tool_cmd" -} - -# Verifies that the chosen merge tool is properly setup. -# Built-in merge tools are always valid. -valid_tool() { - case "$1" in - kdiff3 | kompare | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge) - ;; # happy - *) - if ! valid_custom_tool "$1" - then - return 1 - fi - ;; - esac -} - -# Sets up the merge_tool_path variable. -# This handles the difftool..path configuration. -# This also falls back to mergetool defaults. -init_merge_tool_path() { - merge_tool_path=$(git config difftool."$1".path) - test -z "$merge_tool_path" && - merge_tool_path=$(git config mergetool."$1".path) - if test -z "$merge_tool_path"; then - case "$1" in - vimdiff) - merge_tool_path=vim - ;; - gvimdiff) - merge_tool_path=gvim - ;; - emerge) - merge_tool_path=emacs - ;; - *) - merge_tool_path="$1" - ;; - esac - fi + run_merge_tool "$merge_tool" } # Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values test -n "$GIT_MERGE_TOOL" && merge_tool="$GIT_MERGE_TOOL" test -n "$GIT_DIFF_TOOL" && merge_tool="$GIT_DIFF_TOOL" -# If merge tool was not specified then use the diff.tool -# configuration variable. If that's invalid then reset merge_tool. -# Fallback to merge.tool. -if test -z "$merge_tool"; then - merge_tool=$(git config diff.tool) - test -z "$merge_tool" && - merge_tool=$(git config merge.tool) - if test -n "$merge_tool" && ! valid_tool "$merge_tool"; then - echo >&2 "git config option diff.tool set to unknown tool: $merge_tool" - echo >&2 "Resetting to default..." - unset merge_tool - fi -fi - -# Try to guess an appropriate merge tool if no tool has been set. -if test -z "$merge_tool"; then - # We have a $DISPLAY so try some common UNIX merge tools - if test -n "$DISPLAY"; then - # If gnome then prefer meld, otherwise, prefer kdiff3 or kompare - if test -n "$GNOME_DESKTOP_SESSION_ID" ; then - merge_tool_candidates="meld kdiff3 kompare tkdiff xxdiff gvimdiff diffuse" - else - merge_tool_candidates="kdiff3 kompare tkdiff xxdiff meld gvimdiff diffuse" - fi - fi - if echo "${VISUAL:-$EDITOR}" | grep 'emacs' > /dev/null 2>&1; then - # $EDITOR is emacs so add emerge as a candidate - merge_tool_candidates="$merge_tool_candidates emerge opendiff vimdiff" - elif echo "${VISUAL:-$EDITOR}" | grep 'vim' > /dev/null 2>&1; then - # $EDITOR is vim so add vimdiff as a candidate - merge_tool_candidates="$merge_tool_candidates vimdiff opendiff emerge" - else - merge_tool_candidates="$merge_tool_candidates opendiff emerge vimdiff" - fi - echo "merge tool candidates: $merge_tool_candidates" - - # Loop over each candidate and stop when a valid merge tool is found. - for i in $merge_tool_candidates - do - init_merge_tool_path $i - if type "$merge_tool_path" > /dev/null 2>&1; then - merge_tool=$i - break - fi - done - - if test -z "$merge_tool" ; then - echo "No known merge resolution program available." - exit 1 - fi - -else - # A merge tool has been set, so verify that it's valid. - if ! valid_tool "$merge_tool"; then - echo >&2 "Unknown merge tool $merge_tool" - exit 1 - fi - - init_merge_tool_path "$merge_tool" - - if test -z "$merge_tool_cmd" && ! type "$merge_tool_path" > /dev/null 2>&1; then - echo "The merge tool $merge_tool is not available as '$merge_tool_path'" - exit 1 - fi -fi - +merge_tool=$(get_merge_tool "$merge_tool") || exit +merge_tool_cmd="$(get_merge_tool_cmd "$merge_tool")" +merge_tool_path="$(get_merge_tool_path "$merge_tool")" || exit # Launch the merge tool on each path provided by 'git diff' while test $# -gt 6 -- cgit v1.2.3 From 47d65924a69576bd9f3254f7055de6b37a359596 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 11 Apr 2009 20:41:56 -0700 Subject: mergetool--lib: simplify API usage by removing more global variables The mergetool--lib scriplet was tricky to use because it relied upon the existance of several global shell variables. This removes more global variables so that things are simpler for callers. A side effect is that some variables are recomputed each time run_merge_tool() is called, but the overhead for recomputing them is justified by the simpler implementation. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index b4500368c3..57e8e3256d 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -47,9 +47,9 @@ launch_merge_tool () { test -n "$GIT_MERGE_TOOL" && merge_tool="$GIT_MERGE_TOOL" test -n "$GIT_DIFF_TOOL" && merge_tool="$GIT_DIFF_TOOL" -merge_tool=$(get_merge_tool "$merge_tool") || exit -merge_tool_cmd="$(get_merge_tool_cmd "$merge_tool")" -merge_tool_path="$(get_merge_tool_path "$merge_tool")" || exit +if test -z "$merge_tool"; then + merge_tool="$(get_merge_tool)" || exit +fi # Launch the merge tool on each path provided by 'git diff' while test $# -gt 6 -- cgit v1.2.3 From db367136605868f5971d42501a48820ccdcb8b08 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 9 Jan 2010 20:02:40 -0800 Subject: difftool--helper: Update copyright and remove distracting comments Some of the comments in git-difftool--helper are not needed because the code is sufficiently readable without them. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index 57e8e3256d..1b138083d3 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -3,9 +3,8 @@ # This script is typically launched by using the 'git difftool' # convenience command. # -# Copyright (c) 2009 David Aguilar +# Copyright (c) 2009-2010 David Aguilar -# Load common functions from git-mergetool--lib TOOL_MODE=diff . git-mergetool--lib @@ -20,7 +19,6 @@ should_prompt () { fi } -# Sets up shell variables and runs a merge tool launch_merge_tool () { # Merged is the filename as it appears in the work tree # Local is the contents of a/filename @@ -39,7 +37,6 @@ launch_merge_tool () { read ans fi - # Run the appropriate merge tool command run_merge_tool "$merge_tool" } -- cgit v1.2.3 From 61ed71dcff8448b0700ef032aa1f962649306624 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 9 Jan 2010 20:02:41 -0800 Subject: difftool--helper: Remove use of the GIT_MERGE_TOOL variable An undocumented mis-feature in git-difftool is that it allows you to specify a default difftool by setting GIT_MERGE_TOOL. This behavior was never documented and was included as an oversight back when git-difftool was maintained outside of git. git-mergetool never honored GIT_MERGE_TOOL so neither should git-difftool. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index 1b138083d3..3621f28c79 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -40,11 +40,10 @@ launch_merge_tool () { run_merge_tool "$merge_tool" } -# Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values -test -n "$GIT_MERGE_TOOL" && merge_tool="$GIT_MERGE_TOOL" -test -n "$GIT_DIFF_TOOL" && merge_tool="$GIT_DIFF_TOOL" - -if test -z "$merge_tool"; then +# GIT_DIFF_TOOL indicates that --tool=... was specified +if test -n "$GIT_DIFF_TOOL"; then + merge_tool="$GIT_DIFF_TOOL" +else merge_tool="$(get_merge_tool)" || exit fi -- cgit v1.2.3 From 1c6f5b52b7b13bbc6cf404cb5ef9e64fda37655c Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 9 Jan 2010 20:02:42 -0800 Subject: difftool: Allow specifying unconfigured commands with --extcmd git-difftool requires difftool..cmd configuration even when tools use the standard "$diffcmd $from $to" form. This teaches git-difftool to run these tools in lieu of configuration by allowing the command to be specified on the command line. Reference: http://article.gmane.org/gmane.comp.version-control.git/133377 Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index 3621f28c79..d806eaef54 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -19,6 +19,11 @@ should_prompt () { fi } +# Indicates that --extcmd=... was specified +use_ext_cmd () { + test -n "$GIT_DIFFTOOL_EXTCMD" +} + launch_merge_tool () { # Merged is the filename as it appears in the work tree # Local is the contents of a/filename @@ -33,18 +38,29 @@ launch_merge_tool () { # the user with the real $MERGED name before launching $merge_tool. if should_prompt; then printf "\nViewing: '$MERGED'\n" - printf "Hit return to launch '%s': " "$merge_tool" + if use_ext_cmd; then + printf "Hit return to launch '%s': " \ + "$GIT_DIFFTOOL_EXTCMD" + else + printf "Hit return to launch '%s': " "$merge_tool" + fi read ans fi - run_merge_tool "$merge_tool" + if use_ext_cmd; then + $GIT_DIFFTOOL_EXTCMD "$LOCAL" "$REMOTE" + else + run_merge_tool "$merge_tool" + fi + } -# GIT_DIFF_TOOL indicates that --tool=... was specified -if test -n "$GIT_DIFF_TOOL"; then - merge_tool="$GIT_DIFF_TOOL" -else - merge_tool="$(get_merge_tool)" || exit +if ! use_ext_cmd; then + if test -n "$GIT_DIFF_TOOL"; then + merge_tool="$GIT_DIFF_TOOL" + else + merge_tool="$(get_merge_tool)" || exit + fi fi # Launch the merge tool on each path provided by 'git diff' -- cgit v1.2.3 From 9f3d54d193d9edcf443c9dd62789af5e8e47635c Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Fri, 15 Jan 2010 14:03:44 -0800 Subject: difftool: Use eval to expand '--extcmd' expressions It was not possible to pass quoted commands to '--extcmd'. By using 'eval' we ensure that expressions with spaces and quotes are supported. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index d806eaef54..69f6bcebcb 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -48,11 +48,10 @@ launch_merge_tool () { fi if use_ext_cmd; then - $GIT_DIFFTOOL_EXTCMD "$LOCAL" "$REMOTE" + eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"' else run_merge_tool "$merge_tool" fi - } if ! use_ext_cmd; then -- cgit v1.2.3 From c8a5672ea5cf593708b29f8279bd651c16047c6e Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Fri, 15 Jan 2010 19:10:03 -0800 Subject: difftool: Update copyright notices to list each year separately This is http://www.gnu.org/licenses/gpl-howto.html advises. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index 69f6bcebcb..e43b5d64de 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -3,7 +3,7 @@ # This script is typically launched by using the 'git difftool' # convenience command. # -# Copyright (c) 2009-2010 David Aguilar +# Copyright (c) 2009, 2010 David Aguilar TOOL_MODE=diff . git-mergetool--lib -- cgit v1.2.3 From 4cacc621f80bbd878a320a664dff1440a9358785 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Fri, 22 Jan 2010 17:36:36 +0100 Subject: Make difftool.prompt fall back to mergetool.prompt The documentation states that "git-difftool falls back to git-mergetool config variables when the difftool equivalents have not been defined". Until now, this was not the case for "difftool.prompt". Signed-off-by: Sebastian Schuberth Acked-by: David Aguilar Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index e43b5d64de..524f5ea8ab 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -11,7 +11,8 @@ TOOL_MODE=diff # difftool.prompt controls the default prompt/no-prompt behavior # and is overridden with $GIT_DIFFTOOL*_PROMPT. should_prompt () { - prompt=$(git config --bool difftool.prompt || echo true) + prompt_merge=$(git config --bool mergetool.prompt || echo true) + prompt=$(git config --bool difftool.prompt || echo $prompt_merge) if test "$prompt" = true; then test -z "$GIT_DIFFTOOL_NO_PROMPT" else -- cgit v1.2.3 From 4a689afb030c1cd5aa1c141db94bbf9dde42f05e Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Tue, 14 Dec 2010 10:18:35 +0100 Subject: difftool: provide basename to external tools Currently, only configured diff helpers get the basename of the file being compared. Tools specified with "git difftool -x" only get the names of temporary files for the different versions. Export BASE so that an external tool can read the name from the environment. Rather than using a third argument, this avoids breaking existing scripts which may somewhat carelessly be using "$@" rather than "$1" "$2". Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index 524f5ea8ab..0594bf7ca5 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -49,6 +49,7 @@ launch_merge_tool () { fi if use_ext_cmd; then + export BASE eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"' else run_merge_tool "$merge_tool" -- cgit v1.2.3 From fdd7aa17f805b376f49a1bf031bf1b88eec89ddf Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Thu, 18 Aug 2011 00:23:44 -0700 Subject: difftool--helper: Make style consistent with git Use the predominant conditional style where "then" appears alone on the line after the test expression. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-difftool--helper.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'git-difftool--helper.sh') diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh index 0594bf7ca5..8452890be9 100755 --- a/git-difftool--helper.sh +++ b/git-difftool--helper.sh @@ -13,7 +13,8 @@ TOOL_MODE=diff should_prompt () { prompt_merge=$(git config --bool mergetool.prompt || echo true) prompt=$(git config --bool difftool.prompt || echo $prompt_merge) - if test "$prompt" = true; then + if test "$prompt" = true + then test -z "$GIT_DIFFTOOL_NO_PROMPT" else test -n "$GIT_DIFFTOOL_PROMPT" @@ -37,9 +38,11 @@ launch_merge_tool () { # $LOCAL and $REMOTE are temporary files so prompt # the user with the real $MERGED name before launching $merge_tool. - if should_prompt; then + if should_prompt + then printf "\nViewing: '$MERGED'\n" - if use_ext_cmd; then + if use_ext_cmd + then printf "Hit return to launch '%s': " \ "$GIT_DIFFTOOL_EXTCMD" else @@ -48,7 +51,8 @@ launch_merge_tool () { read ans fi - if use_ext_cmd; then + if use_ext_cmd + then export BASE eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"' else @@ -56,8 +60,10 @@ launch_merge_tool () { fi } -if ! use_ext_cmd; then - if test -n "$GIT_DIFF_TOOL"; then +if ! use_ext_cmd +then + if test -n "$GIT_DIFF_TOOL" + then merge_tool="$GIT_DIFF_TOOL" else merge_tool="$(get_merge_tool)" || exit -- cgit v1.2.3