[PATCH 2/2] created helper function for both winmerge and examdiff mergetools

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

 



Signed-off-by: Jacob Nisnevich <jacob.nisnevich@xxxxxxxxx>
---
 ...s-created-new-mergetool-file-for-ExamDiff.patch | 58 ++++++++++++++++++++++
 mergetools/examdiff                                | 25 ++--------
 mergetools/mergetools_helpers                      | 30 +++++++++++
 mergetools/winmerge                                | 23 ++-------
 4 files changed, 95 insertions(+), 41 deletions(-)
 create mode 100644 0001-mergetools-created-new-mergetool-file-for-ExamDiff.patch
 create mode 100644 mergetools/mergetools_helpers

diff --git a/0001-mergetools-created-new-mergetool-file-for-ExamDiff.patch b/0001-mergetools-created-new-mergetool-file-for-ExamDiff.patch
new file mode 100644
index 0000000..99e0d6b
--- /dev/null
+++ b/0001-mergetools-created-new-mergetool-file-for-ExamDiff.patch
@@ -0,0 +1,58 @@
+From a26ad589bc5e747962359c89c5536858748e5eb8 Mon Sep 17 00:00:00 2001
+From: Jacob Nisnevich <jacob.nisnevich@xxxxxxxxx>
+Date: Sat, 19 Mar 2016 17:31:50 -0700
+Subject: [PATCH] mergetools: created new mergetool file for ExamDiff
+To: git@xxxxxxxxxxxxxxx
+
+---
+ mergetools/examdiff | 37 +++++++++++++++++++++++++++++++++++++
+ 1 file changed, 37 insertions(+)
+ create mode 100644 mergetools/examdiff
+
+diff --git a/mergetools/examdiff b/mergetools/examdiff
+new file mode 100644
+index 0000000..474fffe
+--- /dev/null
++++ b/mergetools/examdiff
+@@ -0,0 +1,37 @@
++diff_cmd () {
++	"$merge_tool_path" "$LOCAL" "$REMOTE" -nh
++}
++
++merge_cmd () {
++	touch "$BACKUP"
++	if $base_present
++	then
++		"$merge_tool_path" -merge "$LOCAL" "$BASE" "$REMOTE" -o:"$MERGED" -nh
++	else
++		"$merge_tool_path" -merge "$LOCAL" "$REMOTE" -o:"$MERGED" -nh
++	fi
++	check_unchanged
++}
++
++translate_merge_tool_path() {
++	# Use ExamDiff.com if it exists in $PATH
++	if type -p ExamDiff.com >/dev/null 2>&1
++	then
++		printf ExamDiff.com
++		return
++	fi
++
++	# Look for ExamDiff.com in the typical locations
++	examdiff="ExamDiff Pro/ExamDiff.com"
++	for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
++		cut -d '=' -f 2- | sort -u)
++	do
++		if test -n "$directory" && test -x "$directory/$examdiff"
++		then
++			printf '%s' "$directory/$examdiff"
++			return
++		fi
++	done
++
++	printf ExamDiff.com
++}
+\ No newline at end of file
+-- 
+1.9.1
+
diff --git a/mergetools/examdiff b/mergetools/examdiff
index 474fffe..8b66c17 100644
--- a/mergetools/examdiff
+++ b/mergetools/examdiff
@@ -1,3 +1,5 @@
+. mergetools_helpers
+
 diff_cmd () {
 	"$merge_tool_path" "$LOCAL" "$REMOTE" -nh
 }
@@ -14,24 +16,5 @@ merge_cmd () {
 }
 
 translate_merge_tool_path() {
-	# Use ExamDiff.com if it exists in $PATH
-	if type -p ExamDiff.com >/dev/null 2>&1
-	then
-		printf ExamDiff.com
-		return
-	fi
-
-	# Look for ExamDiff.com in the typical locations
-	examdiff="ExamDiff Pro/ExamDiff.com"
-	for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
-		cut -d '=' -f 2- | sort -u)
-	do
-		if test -n "$directory" && test -x "$directory/$examdiff"
-		then
-			printf '%s' "$directory/$examdiff"
-			return
-		fi
-	done
-
-	printf ExamDiff.com
-}
\ No newline at end of file
+	mergetool_find_win32_cmd "ExamDiff.com" "ExamDiff Pro"
+}
diff --git a/mergetools/mergetools_helpers b/mergetools/mergetools_helpers
new file mode 100644
index 0000000..6df9d09
--- /dev/null
+++ b/mergetools/mergetools_helpers
@@ -0,0 +1,30 @@
+# Find path to win32 executable using typical locations
+# Arguments
+#  executable      - default name of executable file
+#  folder          - folder containing executable file from Program Files
+# Returns
+#  Path to the executable
+mergetool_find_win32_cmd () {
+	executable = $1
+	folder = $2
+
+	# Use executable.com if it exists in $PATH
+	if type -p $executable >/dev/null 2>&1
+	then
+		printf $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/$folder/$executable"
+		then
+			printf '%s' "$directory/$folder/$executable"
+			return
+		fi
+	done
+
+	printf $executable
+}
diff --git a/mergetools/winmerge b/mergetools/winmerge
index 74a66d4..265d853 100644
--- a/mergetools/winmerge
+++ b/mergetools/winmerge
@@ -1,3 +1,5 @@
+. mergetools_helpers
+
 diff_cmd () {
 	"$merge_tool_path" -u -e "$LOCAL" "$REMOTE"
 	return 0
@@ -13,24 +15,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

--
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]