Skip to content

Commit bfc7ef3

Browse files
committed
Merge branch 'js/drop-mingw-test-cmp'
Use `git diff --no-index` as a test_cmp on Windows. We'd probably need to revisit "do we really want to, and have to, lose CRLF vs LF?" later, at which time we may be able to further clean this up by replacing "git diff --no-index" with "diff -u". * js/drop-mingw-test-cmp: tests(mingw): avoid very slow `mingw_test_cmp`
2 parents 37449fb + a3795bf commit bfc7ef3

File tree

2 files changed

+1
-67
lines changed

2 files changed

+1
-67
lines changed

t/test-lib-functions.sh

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,72 +1450,6 @@ test_skip_or_die () {
14501450
error "$2"
14511451
}
14521452

1453-
# The following mingw_* functions obey POSIX shell syntax, but are actually
1454-
# bash scripts, and are meant to be used only with bash on Windows.
1455-
1456-
# A test_cmp function that treats LF and CRLF equal and avoids to fork
1457-
# diff when possible.
1458-
mingw_test_cmp () {
1459-
# Read text into shell variables and compare them. If the results
1460-
# are different, use regular diff to report the difference.
1461-
local test_cmp_a= test_cmp_b=
1462-
1463-
# When text came from stdin (one argument is '-') we must feed it
1464-
# to diff.
1465-
local stdin_for_diff=
1466-
1467-
# Since it is difficult to detect the difference between an
1468-
# empty input file and a failure to read the files, we go straight
1469-
# to diff if one of the inputs is empty.
1470-
if test -s "$1" && test -s "$2"
1471-
then
1472-
# regular case: both files non-empty
1473-
mingw_read_file_strip_cr_ test_cmp_a <"$1"
1474-
mingw_read_file_strip_cr_ test_cmp_b <"$2"
1475-
elif test -s "$1" && test "$2" = -
1476-
then
1477-
# read 2nd file from stdin
1478-
mingw_read_file_strip_cr_ test_cmp_a <"$1"
1479-
mingw_read_file_strip_cr_ test_cmp_b
1480-
stdin_for_diff='<<<"$test_cmp_b"'
1481-
elif test "$1" = - && test -s "$2"
1482-
then
1483-
# read 1st file from stdin
1484-
mingw_read_file_strip_cr_ test_cmp_a
1485-
mingw_read_file_strip_cr_ test_cmp_b <"$2"
1486-
stdin_for_diff='<<<"$test_cmp_a"'
1487-
fi
1488-
test -n "$test_cmp_a" &&
1489-
test -n "$test_cmp_b" &&
1490-
test "$test_cmp_a" = "$test_cmp_b" ||
1491-
eval "diff -u \"\$@\" $stdin_for_diff"
1492-
}
1493-
1494-
# $1 is the name of the shell variable to fill in
1495-
mingw_read_file_strip_cr_ () {
1496-
# Read line-wise using LF as the line separator
1497-
# and use IFS to strip CR.
1498-
local line
1499-
while :
1500-
do
1501-
if IFS=$'\r' read -r -d $'\n' line
1502-
then
1503-
# good
1504-
line=$line$'\n'
1505-
else
1506-
# we get here at EOF, but also if the last line
1507-
# was not terminated by LF; in the latter case,
1508-
# some text was read
1509-
if test -z "$line"
1510-
then
1511-
# EOF, really
1512-
break
1513-
fi
1514-
fi
1515-
eval "$1=\$$1\$line"
1516-
done
1517-
}
1518-
15191453
# Like "env FOO=BAR some-program", but run inside a subshell, which means
15201454
# it also works for shell functions (though those functions cannot impact
15211455
# the environment outside of the test_env invocation).

t/test-lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,7 @@ case $uname_s in
17211721
test_set_prereq SED_STRIPS_CR
17221722
test_set_prereq GREP_STRIPS_CR
17231723
test_set_prereq WINDOWS
1724-
GIT_TEST_CMP=mingw_test_cmp
1724+
GIT_TEST_CMP="GIT_DIR=/dev/null git diff --no-index --ignore-cr-at-eol --"
17251725
;;
17261726
*CYGWIN*)
17271727
test_set_prereq POSIXPERM

0 commit comments

Comments
 (0)