Subject: Re: [PATCH v3 2/2] tests(mingw): avoid very slow `mingw_test_cmp`

From: Junio C Hamano <[email-masked]>
Date: Mon, 21 Nov 2022 12:13:56 +0900

Johannes Sixt <[email-masked]> writes:

>> Use of "ignore-cr-at-eol" may allow such tests that are not ported
>> correctly to prepare expected output with a "wrong" line ending and
>> still pass, and I do think it may be an expedite way to make tests
>> appear to pass.
>
> The reason that mingw_test_cmp exists is not that Git isn't ported
> correctly, or that tests aren't ported correctly. The reason is that
> tests assume Unix LF line endings everywhere, but there are some tools
> that are outside our control that randomly -- to the layman's eye --
> produce CRLF line endings even when their input has LF style.
>
> For example, when we post-process Git output with `sed`, the result
> suddenly has CRLF line endings instead of LF that the input had.

That's exactly the kind of thing I meant by "porting the tests".

If we _know_ that the tests want to munge something (either the
hardcoded expectation or command output) with LF line ending, and
produce output with LF line ending, then platform tools like 'sed'
used for that task should be told not to turn LF into CRLF, with
something like:

    case $uname_s in
    *MINGW*)
        sed () {
            command sed --binary "$@"
        }
	... other workarounds come here ...
	;;
    easc

before we can call that we ported our tests to the platform.