mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
mergetools: create mergetool_find_win32_cmd() helper function for winmerge
Signed-off-by: Jacob Nisnevich <jacob.nisnevich@gmail.com> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
56331f8727
commit
e36d716751
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user