Git development
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Kristofer Karlsson via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Johannes Sixt <j6t@kdbg.org>,
	Kristofer Karlsson <krka@spotify.com>,
	Collin Funk <collin.funk1@gmail.com>
Subject: Re: [PATCH v3] t: add "test-tool genbytes" to avoid slow tr(1) on macOS
Date: Wed, 11 Nov 2026 11:54:00 +0100	[thread overview]
Message-ID: <avRJPDEJWTGWySKp@pks.im> (raw)
In-Reply-To: <pull.2301.v3.git.1794335168170.gitgitgadget@gmail.com>

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 <char> [<count>]\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 [<count>]\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

  parent reply	other threads:[~2026-11-11 10:54 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07 14:59 [PATCH 0/3] t: add "test-tool genbytes" to avoid slow tr(1) on macOS Kristofer Karlsson via GitGitGadget
2026-11-07 14:59 ` [PATCH 1/3] t/helper: rename test-genzeros.c to test-genbytes.c Kristofer Karlsson via GitGitGadget
2026-11-07 23:15   ` Junio C Hamano
2026-11-08  4:44     ` Junio C Hamano
2026-11-08  9:10       ` Kristofer Karlsson
2026-11-08 18:35         ` Junio C Hamano
2026-11-08 19:10           ` Kristofer Karlsson
2026-11-07 14:59 ` [PATCH 2/3] t: add "test-tool genbytes" to avoid slow tr(1) on macOS Kristofer Karlsson via GitGitGadget
2026-11-08  8:54   ` Johannes Sixt
2026-11-08  9:18     ` Kristofer Karlsson
2026-11-08  9:35       ` Johannes Sixt
2026-11-08 12:24         ` Kristofer Karlsson
2026-11-08 16:34           ` Johannes Sixt
2026-11-09  9:33             ` Johannes Sixt
2026-11-09 13:05               ` Kristofer Karlsson
2026-11-09 15:38                 ` Johannes Sixt
2026-11-10  6:00       ` Collin Funk
2026-11-10  8:09         ` Kristofer Karlsson
2026-11-08 18:37     ` Junio C Hamano
2026-11-07 14:59 ` [PATCH 3/3] t: replace "test-tool genzeros" with "genbytes NUL" Kristofer Karlsson via GitGitGadget
2026-11-07 23:04 ` [PATCH 0/3] t: add "test-tool genbytes" to avoid slow tr(1) on macOS Junio C Hamano
2026-11-08  9:11   ` Kristofer Karlsson
2026-11-07 23:23 ` Junio C Hamano
2026-11-08  9:13   ` Kristofer Karlsson
2026-11-08 19:15 ` [PATCH v2 0/2] " Kristofer Karlsson via GitGitGadget
2026-11-08 19:15   ` [PATCH v2 1/2] " Kristofer Karlsson via GitGitGadget
2026-11-09  1:39     ` Junio C Hamano
2026-11-09  7:10       ` Kristofer Karlsson
2026-11-09 15:41         ` Junio C Hamano
2026-11-09  6:59     ` Patrick Steinhardt
2026-11-09  7:43       ` Kristofer Karlsson
2026-11-08 19:15   ` [PATCH v2 2/2] t: replace "test-tool genzeros" with "genbytes 00" Kristofer Karlsson via GitGitGadget
2026-11-10 18:26 ` [PATCH v3] t: add "test-tool genbytes" to avoid slow tr(1) on macOS Kristofer Karlsson via GitGitGadget
2026-11-10 19:31   ` Junio C Hamano
2026-11-11 10:54   ` Patrick Steinhardt [this message]
2026-11-11 15:38   ` Junio C Hamano
2026-11-11 15:47     ` Kristofer Karlsson
2026-11-11 17:57       ` Junio C Hamano
2026-11-11 15:59 ` [PATCH v4] " Kristofer Karlsson via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=avRJPDEJWTGWySKp@pks.im \
    --to=ps@pks.im \
    --cc=collin.funk1@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=j6t@kdbg.org \
    --cc=krka@spotify.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox