git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 6/8] t1901: use tr in git repo structure output instead of expected value

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 20, 2026, 10:12 UTC
Message-ID
<aZgzmlVfuXgI2UJ9@pks.im>
In-Reply-To
<20260218211845.96009-7-lucasseikioshiro@gmail.com>
On Wed, Feb 18, 2026 at 06:08:42PM -0300, Lucas Seiki Oshiro wrote:
Show 6 quoted lines
> 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.

Hm, okay. I have to admit I don't quite understand what we gain here. We have to use tr(1) regardless of how we do it, and I cannot see that either of these alternatives is clearly superior compared to the other.

Show 12 quoted lines
> diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
> index a6f2591d9a..4de795181f 100755
> --- a/t/t1901-repo-structure.sh
> +++ b/t/t1901-repo-structure.sh
> @@ -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" "=" <out | tr "\000" "\012" >actual &&
We can combine the two calls to tr(1) to a single one.
Show 8 quoted lines
> -		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" "=" <out | tr "\000" "\012" >actual &&
Same here.
Patrick
Previous: Lucas Seiki OshiroNext: Lucas Seiki Oshiro
Message 10 of 24 in “repo: refactoring leftover nits”
  1. 0/8 repo: refactoring leftover nitsLucas Seiki Oshiro, Feb 18, 2026
  2. 1/8 CodingGuidelines: instruct to name arrays in singularLucas Seiki Oshiro, Feb 18, 2026
  3. Eric SunshineFeb 19, 2026
  4. Lucas Seiki OshiroFeb 22, 2026
  5. 2/8 repo: rename repo_info_fields to repo_info_fieldLucas Seiki Oshiro, Feb 18, 2026
  6. 3/8 repo: replace get_value_fn_for_key by get_repo_info_fieldLucas Seiki Oshiro, Feb 18, 2026
  7. 4/8 repo: rename struct field to repo_info_fieldLucas Seiki Oshiro, Feb 18, 2026
  8. 5/8 t1900: rename t1900-repo to t1900-repo-infoLucas Seiki Oshiro, Feb 18, 2026
  9. 6/8 t1901: use tr in git repo structure output instead of expected valueLucas Seiki Oshiro, Feb 18, 2026
  10. Patrick SteinhardtFeb 20, 2026
  11. Lucas Seiki OshiroFeb 22, 2026
  12. 7/8 Documentation/git-repo: replace 'NUL' with '_NUL_'Lucas Seiki Oshiro, Feb 18, 2026
  13. 8/8 Documentation/git-repo: capitalize format descriptionsLucas Seiki Oshiro, Feb 18, 2026
  14. 0/8 repo: refactoring leftover nitsLucas Seiki Oshiro, Feb 25, 2026
  15. 1/8 CodingGuidelines: instruct to name arrays in singularLucas Seiki Oshiro, Feb 25, 2026
  16. 2/8 repo: rename repo_info_fields to repo_info_fieldLucas Seiki Oshiro, Feb 25, 2026
  17. 3/8 repo: replace get_value_fn_for_key by get_repo_info_fieldLucas Seiki Oshiro, Feb 25, 2026
  18. 4/8 repo: rename struct field to repo_info_fieldLucas Seiki Oshiro, Feb 25, 2026
  19. 5/8 t1900: rename t1900-repo to t1900-repo-infoLucas Seiki Oshiro, Feb 25, 2026
  20. 6/8 t1901: adjust nul format output instead of expected valueLucas Seiki Oshiro, Feb 25, 2026
  21. 7/8 Documentation/git-repo: replace 'NUL' with '_NUL_'Lucas Seiki Oshiro, Feb 25, 2026
  22. 8/8 Documentation/git-repo: capitalize format descriptionsLucas Seiki Oshiro, Feb 25, 2026
  23. Lucas Seiki OshiroFeb 25, 2026
  24. Junio C HamanoFeb 25, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.