]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t1901: adjust nul format output instead of expected value
authorLucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Wed, 25 Feb 2026 16:32:15 +0000 (13:32 -0300)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Feb 2026 19:47:43 +0000 (11:47 -0800)
The test 'keyvalue and nul format', as it description says, test both
`keyvalue` and `nul` format. These formats are similar, differing only in
their field separator (= in the former, LF in the latter) and their
record separator (LF in the former, NUL in the latter). This way, both
formats can be tested using the same expected output and only replacing
the separators in one of the output formats.

However, it is not desirable to have a NUL character in the files
compared by test_cmp because, if that assetion fails, diff will consider
them binary files and won't display the differences properly.

Adjust the output of `git repo structure --format=nul` in t1901, matching the
--format=keyvalue ones. Compare this output against the same value expected
from --format=keyvalue, without using files with NUL characters in
test_cmp.

Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1901-repo-structure.sh

index a6f2591d9a61ff15c14e693ca1af72c549f9c99d..a67b38ab1781259e24c558ce953850e9e1920d05 100755 (executable)
@@ -145,18 +145,18 @@ test_expect_success SHA1 'lines and nul format' '
                test_cmp expect out &&
                test_line_count = 0 err &&
 
-               # Replace key and value delimiters for nul format.
-               tr "\n=" "\0\n" <expect >expect_nul &&
                git repo structure --format=nul >out 2>err &&
+               tr "\012\000" "=\012" <out >actual &&
 
-               test_cmp expect_nul out &&
+               test_cmp expect actual &&
                test_line_count = 0 err &&
 
                # "-z", as a synonym to "--format=nul", participates in the
                # usual "last one wins" rule.
                git repo structure --format=table -z >out 2>err &&
+               tr "\012\000" "=\012" <out >actual &&
 
-               test_cmp expect_nul out &&
+               test_cmp expect actual &&
                test_line_count = 0 err
        )
 '