Skip to content

Commit cb75bcb

Browse files
committed
tests: only override sort & find if there are usable ones in /usr/bin/
The idea is to allow running the test suite on MinGit with BusyBox installed in /mingw64/bin/sh.exe. In that case, we will want to exclude sort & find (and other Unix utilities) from being bundled. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 42d4705 commit cb75bcb

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

git-sh-setup.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,20 @@ create_virtual_base() {
332332
# Platform specific tweaks to work around some commands
333333
case $(uname -s) in
334334
*MINGW*)
335-
# Windows has its own (incompatible) sort and find
336-
sort () {
337-
/usr/bin/sort "$@"
338-
}
339-
find () {
340-
/usr/bin/find "$@"
341-
}
335+
if test -x /usr/bin/sort
336+
then
337+
# Windows has its own (incompatible) sort; override
338+
sort () {
339+
/usr/bin/sort "$@"
340+
}
341+
fi
342+
if test -x /usr/bin/find
343+
then
344+
# Windows has its own (incompatible) find; override
345+
find () {
346+
/usr/bin/find "$@"
347+
}
348+
fi
342349
# git sees Windows-style pwd
343350
pwd () {
344351
builtin pwd -W

t/test-lib.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,13 +1035,20 @@ yes () {
10351035
uname_s=$(uname -s)
10361036
case $uname_s in
10371037
*MINGW*)
1038-
# Windows has its own (incompatible) sort and find
1039-
sort () {
1040-
/usr/bin/sort "$@"
1041-
}
1042-
find () {
1043-
/usr/bin/find "$@"
1044-
}
1038+
if test -x /usr/bin/sort
1039+
then
1040+
# Windows has its own (incompatible) sort; override
1041+
sort () {
1042+
/usr/bin/sort "$@"
1043+
}
1044+
fi
1045+
if test -x /usr/bin/find
1046+
then
1047+
# Windows has its own (incompatible) find; override
1048+
find () {
1049+
/usr/bin/find "$@"
1050+
}
1051+
fi
10451052
# git sees Windows-style pwd
10461053
pwd () {
10471054
builtin pwd -W

0 commit comments

Comments
 (0)