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

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

 



This refactors git-mergetool to use valid_tool from git-mergetool-lib.

Signed-off-by: David Aguilar <davvid@xxxxxxxxx>
---
 git-mergetool.sh |   21 +++------------------
 1 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/git-mergetool.sh b/git-mergetool.sh
index 732a5b7..957993c 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -11,6 +11,7 @@
 USAGE='[--tool=tool] [-y|--no-prompt|--prompt] [file to merge] ...'
 SUBDIRECTORY_OK=Yes
 OPTIONS_SPEC=
+TOOL_MODE=merge
 . git-sh-setup
 . git-mergetool-lib
 require_work_tree
@@ -338,24 +339,6 @@ do
     shift
 done
 
-valid_custom_tool()
-{
-    merge_tool_cmd="$(git config mergetool.$1.cmd)"
-    test -n "$merge_tool_cmd"
-}
-
-valid_tool() {
-	case "$1" in
-		kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
-			;; # happy
-		*)
-			if ! valid_custom_tool "$1"; then
-				return 1
-			fi
-			;;
-	esac
-}
-
 prompt_after_failed_merge() {
     while true; do
 	printf "Continue merging other unresolved paths (y/n) ? "
@@ -409,12 +392,14 @@ if test -z "$merge_tool" ; then
 	echo "No known merge resolution program available."
 	exit 1
     fi
+    merge_tool_cmd="$(git config mergetool."$merge_tool".cmd)"
 else
     if ! valid_tool "$merge_tool"; then
         echo >&2 "Unknown merge_tool $merge_tool"
         exit 1
     fi
 
+    merge_tool_cmd="$(git config mergetool.$merge_tool.cmd)"
     merge_tool_path="$(get_merge_tool_path "$merge_tool")"
     merge_keep_backup="$(git config --bool merge.keepBackup || echo true)"
     merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
-- 
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