t8002: fix ambiguous printf conversion specifications

In e7fb2ca945 (builtin/blame: fix out-of-bounds write with blank boundary commits, 2025-01-10), we have introduced two new tests that expect a certain amount of padding. This padding is generated via printf using the "%0.s" conversion specification. That directive is ambiguous because it might be interpreted as field width (most shells) or 0-padding flag for numeric fields (coreutils). Fix this issue by using "%${N}s" instead, which is already being used in other tests (i.e. t5300, t0450) and is unambiguous. Helped-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Jan Palus <jpalus@fastmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jan Palus committed Jan 20, 2025 at 12:41 UTC 2d0ff147e5f6a46554605d137993ba385698eb4e
1 file changed +2 -2
t/t8002-blame.sh
+2 -2
@@ -138,7 +138,7 @@ test_expect_success 'blame --abbrev -b truncates the blank boundary' '
138 # Note that `--abbrev=` always gets incremented by 1, which is why we
139 # expect 11 leading spaces and not 10.
140 cat >expect <<-EOF &&
141 - $(printf "%0.s " $(test_seq 11)) (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
141 + $(printf "%11s" "") (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
142 EOF
143 git blame -b --abbrev=10 ^HEAD -- abbrev.t >actual &&
144 test_cmp expect actual
@@ -146,7 +146,7 @@ test_expect_success 'blame --abbrev -b truncates the blank boundary' '
146
147 test_expect_success 'blame with excessive --abbrev and -b culls to hash length' '
148 cat >expect <<-EOF &&
149 - $(printf "%0.s " $(test_seq $hexsz)) (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
149 + $(printf "%${hexsz}s" "") (<author@example.com> 2005-04-07 15:45:13 -0700 1) abbrev
150 EOF
151 git blame -b --abbrev=9000 ^HEAD -- abbrev.t >actual &&
152 test_cmp expect actual