t1901: adjust nul format output instead of expected value

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>

Lucas Seiki Oshiro committed Feb 25, 2026 at 13:32 UTC 2db3d0a2268c1bdd1b9d1bf8e5f46be3ba7cb8bf
1 file changed +4 -4
t/t1901-repo-structure.sh
+4 -4
@@ -145,18 +145,18 @@ test_expect_success SHA1 'lines and nul format' '
145 test_cmp expect out &&
146 test_line_count = 0 err &&
147
148 - # Replace key and value delimiters for nul format.
149 - tr "\n=" "\0\n" <expect >expect_nul &&
148 git repo structure --format=nul >out 2>err &&
149 + tr "\012\000" "=\012" <out >actual &&
150
152 - test_cmp expect_nul out &&
151 + test_cmp expect actual &&
152 test_line_count = 0 err &&
153
154 # "-z", as a synonym to "--format=nul", participates in the
155 # usual "last one wins" rule.
156 git repo structure --format=table -z >out 2>err &&
157 + tr "\012\000" "=\012" <out >actual &&
158
159 - test_cmp expect_nul out &&
159 + test_cmp expect actual &&
160 test_line_count = 0 err
161 )
162 '