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

From: Junio C Hamano <[email-masked]>
Date: Tue, 21 Jan 2025 14:10:14 -0800

Jan Palus <[email-masked]> writes:

> -	$(printf "%0.s " $(test_seq 11)) (<[email-masked]> 2005-04-07 15:45:13 -0700 1) abbrev
> +	$(printf "%11s" "") (<[email-masked]> 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.

> @@ -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)) (<[email-masked]> 2005-04-07 15:45:13 -0700 1) abbrev
> +	$(printf "%${hexsz}s" "") (<[email-masked]> 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.