[PATCH 07/10] difftool: use valid_tool from git-mergetool-lib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This refactors difftool to use valid_tool fro git-mergetool-lib

Signed-off-by: David Aguilar <davvid@xxxxxxxxx>
---
 git-difftool-helper.sh |   29 +++--------------------------
 1 files changed, 3 insertions(+), 26 deletions(-)

diff --git a/git-difftool-helper.sh b/git-difftool-helper.sh
index d1bea18..6cc5ab5 100755
--- a/git-difftool-helper.sh
+++ b/git-difftool-helper.sh
@@ -8,6 +8,7 @@
 # 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
@@ -105,29 +106,6 @@ launch_merge_tool () {
 	esac
 }
 
-# Verifies that (difftool|mergetool).<tool>.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
-}
-
 # 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"
@@ -183,6 +161,7 @@ if test -z "$merge_tool"; then
 		exit 1
 	fi
 
+	merge_tool_cmd=$(get_custom_cmd "$merge_tool")
 else
 	# A merge tool has been set, so verify that it's valid.
 	if ! valid_tool "$merge_tool"; then
@@ -190,9 +169,7 @@ else
 		exit 1
 	fi
 
-	# Sets up the merge_tool_path variable.
-	# This handles the difftool.<tool>.path configuration variable
-	# and falls back to mergetool defaults.
+	merge_tool_cmd=$(get_custom_cmd "$merge_tool")
 	merge_tool_path=$(git config difftool."$1".path)
 	test -z "$merge_tool_path" &&
 	merge_tool_path=$(git config mergetool."$1".path)
-- 
1.6.1.3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux