git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Aguilar <davvid@gmail.com>
To: gitster@pobox.com, charles@hashpling.org
Cc: git@vger.kernel.org, David Aguilar <davvid@gmail.com>
Subject: [PATCH 05/10] difftool: use get_mergetool_path from git-mergetool-lib
Date: Wed,  1 Apr 2009 05:55:09 -0700	[thread overview]
Message-ID: <1238590514-41893-6-git-send-email-davvid@gmail.com> (raw)
In-Reply-To: <1238590514-41893-5-git-send-email-davvid@gmail.com>

This refactors git-difftool-helper to use get_mergetool_path().

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 git-difftool-helper.sh |   33 ++++++++++++---------------------
 1 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/git-difftool-helper.sh b/git-difftool-helper.sh
index 02bb135..d1bea18 100755
--- a/git-difftool-helper.sh
+++ b/git-difftool-helper.sh
@@ -7,6 +7,9 @@
 #
 # Copyright (c) 2009 David Aguilar
 
+# Load common functions from git-mergetool-lib
+. git-mergetool-lib
+
 # difftool.prompt controls the default prompt/no-prompt behavior
 # and is overridden with $GIT_DIFFTOOL*_PROMPT.
 should_prompt () {
@@ -125,25 +128,6 @@ valid_tool() {
 	esac
 }
 
-# Sets up the merge_tool_path variable.
-# This handles the difftool.<tool>.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
-		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"
@@ -187,7 +171,7 @@ if test -z "$merge_tool"; then
 	# 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
+		merge_tool_path="$(get_merge_tool_path "$i")"
 		if type "$merge_tool_path" > /dev/null 2>&1; then
 			merge_tool=$i
 			break
@@ -206,7 +190,14 @@ else
 		exit 1
 	fi
 
-	init_merge_tool_path "$merge_tool"
+	# Sets up the merge_tool_path variable.
+	# This handles the difftool.<tool>.path configuration variable
+	# and falls back to mergetool defaults.
+	merge_tool_path=$(git config difftool."$1".path)
+	test -z "$merge_tool_path" &&
+	merge_tool_path=$(git config mergetool."$1".path)
+	merge_tool_path="$(get_merge_tool_path "$merge_tool" \
+	                                       "$merge_tool_path")"
 
 	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'"
-- 
1.6.1.3

  reply	other threads:[~2009-04-01 12:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-01 12:55 git-{diff,merge} refactor round 2 David Aguilar
2009-04-01 12:55 ` [PATCH 01/10] difftool: add support for a difftool.prompt config variable David Aguilar
2009-04-01 12:55   ` [PATCH 02/10] mergetool: use $( ... ) instead of `backticks` David Aguilar
2009-04-01 12:55     ` [PATCH 03/10] Add a mergetool-lib scriptlet for holding common merge tool functions David Aguilar
2009-04-01 12:55       ` [PATCH 04/10] mergetool: use get_mergetool_path from git-mergetool-lib David Aguilar
2009-04-01 12:55         ` David Aguilar [this message]
2009-04-01 12:55           ` [PATCH 06/10] mergetool: use valid_tool " David Aguilar
2009-04-01 12:55             ` [PATCH 07/10] difftool: " David Aguilar
2009-04-01 12:55               ` [PATCH 08/10] mergetool-lib: introduce run_mergetool David Aguilar
2009-04-01 12:55                 ` [PATCH 09/10] difftool: use run_mergetool from git-mergetool-lib David Aguilar
2009-04-01 12:55                   ` [PATCH 10/10] mergetool: " David Aguilar
2009-04-01 22:54                     ` Markus Heidelberg
2009-04-02 20:02                       ` Charles Bailey
2009-04-02 20:13                         ` Markus Heidelberg
2009-04-02 20:16                           ` Markus Heidelberg
2009-04-03  1:54                           ` David Aguilar
2009-04-01 22:47                 ` [PATCH 08/10] mergetool-lib: introduce run_mergetool Markus Heidelberg
2009-04-01 22:39       ` [PATCH 03/10] Add a mergetool-lib scriptlet for holding common merge tool functions Markus Heidelberg
2009-04-02  3:58         ` David Aguilar
2009-04-02 19:59 ` git-{diff,merge} refactor round 2 Charles Bailey
2009-04-05  2:58 ` Markus Heidelberg
2009-04-05  3:34   ` David Aguilar
2009-04-05  9:45     ` Junio C Hamano
2009-04-05 21:15       ` David Aguilar
2009-04-05 22:15         ` Markus Heidelberg
2009-04-06  0:33           ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1238590514-41893-6-git-send-email-davvid@gmail.com \
    --to=davvid@gmail.com \
    --cc=charles@hashpling.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).