git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jacob Nisnevich <jacob.nisnevich@gmail.com>
To: davvid@gmail.com
Cc: gitster@pobox.com, git@vger.kernel.org,
	Jacob Nisnevich <jacob.nisnevich@gmail.com>
Subject: [PATCH 1/2] mergetools: create mergetool_find_win32_cmd() helper function for winmerge
Date: Fri, 25 Mar 2016 16:17:56 -0700	[thread overview]
Message-ID: <1458947877-31764-2-git-send-email-jacob.nisnevich@gmail.com> (raw)
In-Reply-To: <1458947877-31764-1-git-send-email-jacob.nisnevich@gmail.com>

Signed-off-by: Jacob Nisnevich <jacob.nisnevich@gmail.com>
---
 git-mergetool--lib.sh | 25 +++++++++++++++++++++++++
 mergetools/winmerge   | 21 +--------------------
 2 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 54ac8e4..302c56d 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -372,3 +372,28 @@ get_merge_tool () {
 	fi
 	echo "$merge_tool"
 }
+
+mergetool_find_win32_cmd () {
+	executable=$1
+	sub_directory=$2
+
+	# Use $executable if it exists in $PATH
+	if type -p "$executable" >/dev/null 2>&1
+	then
+		printf '%s' "$executable"
+		return
+	fi
+
+	# Look for executable in the typical locations
+	for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
+		cut -d '=' -f 2- | sort -u)
+	do
+		if test -n "$directory" && test -x "$directory/$sub_directory/$executable"
+		then
+			printf '%s' "$directory/$sub_directory/$executable"
+			return
+		fi
+	done
+
+	printf '%s' "$executable"
+}
diff --git a/mergetools/winmerge b/mergetools/winmerge
index 74a66d4..f3819d3 100644
--- a/mergetools/winmerge
+++ b/mergetools/winmerge
@@ -13,24 +13,5 @@ merge_cmd () {
 }
 
 translate_merge_tool_path() {
-	# Use WinMergeU.exe if it exists in $PATH
-	if type -p WinMergeU.exe >/dev/null 2>&1
-	then
-		printf WinMergeU.exe
-		return
-	fi
-
-	# Look for WinMergeU.exe in the typical locations
-	winmerge_exe="WinMerge/WinMergeU.exe"
-	for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
-		cut -d '=' -f 2- | sort -u)
-	do
-		if test -n "$directory" && test -x "$directory/$winmerge_exe"
-		then
-			printf '%s' "$directory/$winmerge_exe"
-			return
-		fi
-	done
-
-	printf WinMergeU.exe
+	mergetool_find_win32_cmd "WinMergeU.exe" "WinMerge"
 }
-- 
1.9.1

  reply	other threads:[~2016-03-25 23:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-20  4:58 [PATCH] mergetools: created new mergetool file for ExamDiff Jacob Nisnevich
2016-03-21  1:02 ` Junio C Hamano
2016-03-21  3:32   ` David Aguilar
2016-03-23  0:43     ` [PATCH 0/2] Helper function for ExamDiff and Winmerge mergetools Jacob Nisnevich
2016-03-23  0:43       ` [PATCH 1/2] mergetools: created new mergetool file for ExamDiff Jacob Nisnevich
2016-03-23  0:43       ` [PATCH 2/2] created helper function for both winmerge and examdiff mergetools Jacob Nisnevich
2016-03-23  2:41         ` Junio C Hamano
2016-03-23 22:55           ` [PATCH] mergetools: implemented new mergetool file for ExamDiff Jacob Nisnevich
2016-03-23 22:55             ` Jacob Nisnevich
2016-03-24  7:44               ` David Aguilar
2016-03-24 15:43                 ` Junio C Hamano
2016-03-25 22:52                   ` [PATCH 0/2] add support " Jacob Nisnevich
2016-03-25 22:52                     ` [PATCH 1/2] mergetools: create mergetool_find_win32_cmd() helper function for winmerge Jacob Nisnevich
2016-03-25 23:00                       ` Junio C Hamano
2016-03-25 23:17                         ` [PATCH 0/2] mergetools: add support for ExamDiff Jacob Nisnevich
2016-03-25 23:17                           ` Jacob Nisnevich [this message]
2016-03-25 23:17                           ` [PATCH 2/2] " Jacob Nisnevich
2016-04-01 18:10                           ` [PATCH 0/2] " Junio C Hamano
2016-04-02 21:02                             ` David Aguilar
2016-03-25 22:52                     ` [PATCH 2/2] " Jacob Nisnevich

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=1458947877-31764-2-git-send-email-jacob.nisnevich@gmail.com \
    --to=jacob.nisnevich@gmail.com \
    --cc=davvid@gmail.com \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).