@@ -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
This complicated heuristics look like a cut-and-paste from the
neighbouring winmerge; makes me suspect that they should share the
same helper function to implement the bulk of the above code for
better maintainability (e.g. imagine in the future Microsoft decides
to introduce another directory organization and makes it necessary
to tweak the pattern you give to 'grep -Ei'---WinMergeU user may
notice that and fix it, while this script will be overlooked and
will stay stale until somebody from examdiff camp do the same fix
later).
@@ -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
This complicated heuristics look like a cut-and-paste from the
neighbouring winmerge; makes me suspect that they should share the
same helper function to implement the bulk of the above code for
better maintainability (e.g. imagine in the future Microsoft decides
to introduce another directory organization and makes it necessary
to tweak the pattern you give to 'grep -Ei'---WinMergeU user may
notice that and fix it, while this script will be overlooked and
will stay stale until somebody from examdiff camp do the same fix
later).
I agree with that.
Something like mergetool_find_win32_cmd() might make sense as a
helper function that we can reuse here.
From: Jacob Nisnevich <hidden> Date: 2016-06-15 23:08:54
I've been trying to implement a helper function for both Winmerge and ExamDiff
as you requested, but for some reason including another shell script with . or
source seems to fail on Windows in this case. I've attached the patches for the
two commits I've made so far. Is there anything I'm doing wrong or is it an
issue with Windows?
Jacob Nisnevich (2):
mergetools: created new mergetool file for ExamDiff
created helper function for both winmerge and examdiff mergetools
...s-created-new-mergetool-file-for-ExamDiff.patch | 58 ++++++++++++++++++++++
mergetools/examdiff | 20 ++++++++
mergetools/mergetools_helpers | 30 +++++++++++
mergetools/winmerge | 23 ++-------
4 files changed, 111 insertions(+), 20 deletions(-)
create mode 100644 0001-mergetools-created-new-mergetool-file-for-ExamDiff.patch
create mode 100644 mergetools/examdiff
create mode 100644 mergetools/mergetools_helpers
--
1.9.1
@@ -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+}