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

Re: [PATCH v2] t8002: fix ambiguous printf conversion specifications

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 21, 2025, 22:10 UTC
Message-ID
<xmqqplkfyg1l.fsf@gitster.g>
In-Reply-To
<20250120114106.2844157-1-jpalus@fastmail.com>
Jan Palus <jpalus@fastmail.com> writes:
> -	$(printf "%0.s " $(test_seq 11)) (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
> +	$(printf "%11s" "") (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev

This obviously is much clearer than the obscure original that concatenates " " 11 times (for 11 arguments that printf receives).

Nice.
Show 6 quoted lines
> @@ -146,7 +146,7 @@ test_expect_success 'blame --abbrev -b truncates the blank boundary' '
>  
>  test_expect_success 'blame with excessive --abbrev and -b culls to hash length' '
>  	cat >expect <<-EOF &&
> -	$(printf "%0.s " $(test_seq $hexsz)) (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
> +	$(printf "%${hexsz}s" "") (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev

The fact that $hexsz was not quoted in the original made me look at how it is defined (as an unquoted variable reference is often a way to lose unwanted leading whitespaces, e.g. bytes=$(wc -c <foo) && show $bytes), but it seems that hexsz would not get any leading (or trailing) whitespaces so this rewrite perfectly fine.

Thanks.  Will queue.
Previous: Jan Palus
Message 2 of 2 in “t8002: fix ambiguous printf conversion specifications”
  1. t8002: fix ambiguous printf conversion specificationsJan Palus, Jan 20, 2025
  2. Junio C HamanoJan 21, 2025

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.