From: Patrick Steinhardt Date: Wed, 11 Nov 2026 10:54:00 GMT Subject: Re: [PATCH v3] t: add "test-tool genbytes" to avoid slow tr(1) on macOS Message-ID: In-Reply-To: On Tue, Nov 10, 2026 at 06:26:08PM +0000, Kristofer Karlsson via GitGitGadget wrote: > diff --git a/t/helper/test-genzeros.c b/t/helper/test-genzeros.c > index b895436a32..e8d83d5012 100644 > --- a/t/helper/test-genzeros.c > +++ b/t/helper/test-genzeros.c > @@ -35,3 +33,29 @@ int cmd__genzeros(int argc, const char **argv) > > return 0; > } > + > +int cmd__genbytes(int argc, const char **argv) > +{ > + intmax_t count = -1; > + > + if (argc < 2 || argc > 3 || strlen(argv[1]) != 1 || > + (argc == 3 && !git_parse_signed(argv[2], &count, INTMAX_MAX))) { > + fprintf(stderr, "usage: %s []\n", argv[0]); > + return 1; > + } > + > + return generate_bytes(argv[1][0], count); > +} Okay, so instead of interpreting `argv[0]` we now just take it as-is and verify that it's a single character, only. That makes users way easier to reason about because you don't have to wonder about how the argument is encoded. It's also extensible because we can easily introduce longer strings or "\x00" and "\000" eventually without breaking any existing callers. > +int cmd__genzeros(int argc, const char **argv) > +{ > + intmax_t count = -1; > + > + if (argc > 2 || > + (argc == 2 && !git_parse_signed(argv[1], &count, INTMAX_MAX))) { > + fprintf(stderr, "usage: %s []\n", argv[0]); > + return 1; > + } > + > + return generate_bytes('\0', count); > +} And this one here is trivially adapted. > diff --git a/t/t0613-reftable-write-options.sh b/t/t0613-reftable-write-options.sh > index 0b27d75fe3..0b74ff6157 100755 > --- a/t/t0613-reftable-write-options.sh > +++ b/t/t0613-reftable-write-options.sh > @@ -146,7 +146,7 @@ test_expect_success 'small block size fails with large reflog message' ' > ( > cd repo && > test_commit A && > - test-tool genzeros 500 | tr "\000" "a" >logmsg && > + test-tool genbytes a 500 >logmsg && > cat >expect <<-EOF && > fatal: update_ref failed for ref ${SQ}refs/heads/logme${SQ}: reftable: transaction failure: entry too large > EOF And all of the callers are easier to understand now. Thanks, this looks great! Patrick