Skip to content

Commit b1b5aa3

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 5f3c0e6 commit b1b5aa3

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
@@ -308,13 +308,20 @@ create_virtual_base() {
308308
# Platform specific tweaks to work around some commands
309309
case $(uname -s) in
310310
*MINGW*)
311-
# Windows has its own (incompatible) sort and find
312-
sort () {
313-
/usr/bin/sort "$@"
314-
}
315-
find () {
316-
/usr/bin/find "$@"
317-
}
311+
if test -x /usr/bin/sort
312+
then
313+
# Windows has its own (incompatible) sort; override
314+
sort () {
315+
/usr/bin/sort "$@"
316+
}
317+
fi
318+
if test -x /usr/bin/find
319+
then
320+
# Windows has its own (incompatible) find; override
321+
find () {
322+
/usr/bin/find "$@"
323+
}
324+
fi
318325
# git sees Windows-style pwd
319326
pwd () {
320327
builtin pwd -W

t/test-lib.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,13 +1520,20 @@ fi
15201520
uname_s=$(uname -s)
15211521
case $uname_s in
15221522
*MINGW*)
1523-
# Windows has its own (incompatible) sort and find
1524-
sort () {
1525-
/usr/bin/sort "$@"
1526-
}
1527-
find () {
1528-
/usr/bin/find "$@"
1529-
}
1523+
if test -x /usr/bin/sort
1524+
then
1525+
# Windows has its own (incompatible) sort; override
1526+
sort () {
1527+
/usr/bin/sort "$@"
1528+
}
1529+
fi
1530+
if test -x /usr/bin/find
1531+
then
1532+
# Windows has its own (incompatible) find; override
1533+
find () {
1534+
/usr/bin/find "$@"
1535+
}
1536+
fi
15301537
# git sees Windows-style pwd
15311538
pwd () {
15321539
builtin pwd -W

0 commit comments

Comments
 (0)