Skip to content

Commit

Permalink
Merge branch 'jn/mergetools-examdiff'
Browse files Browse the repository at this point in the history
"git mergetools" learned to drive ExamDiff.

* jn/mergetools-examdiff:
  mergetools: add support for ExamDiff
  mergetools: create mergetool_find_win32_cmd() helper function for winmerge
  • Loading branch information
gitster committed Apr 13, 2016
2 parents 7929674 + 35d62bb commit 34e859d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 20 deletions.
25 changes: 25 additions & 0 deletions git-mergetool--lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
18 changes: 18 additions & 0 deletions mergetools/examdiff
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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() {
mergetool_find_win32_cmd "ExamDiff.com" "ExamDiff Pro"
}
21 changes: 1 addition & 20 deletions mergetools/winmerge
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 34e859d

Please sign in to comment.