From: Junio C Hamano <gitster@pobox.com>
To: "Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
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: Tue, 10 Nov 2026 11:31:16 -0800 [thread overview]
Message-ID: <xmqqo6bwqy9n.fsf@gitster.g> (raw)
In-Reply-To: <pull.2301.v3.git.1794335168170.gitgitgadget@gmail.com> (Kristofer Karlsson via GitGitGadget's message of "Tue, 10 Nov 2026 18:26:08 +0000")
> * test-genzeros.c is no longer renamed, and "genbytes" lives next to
> "genzeros" in the same file. Since "genzeros" stays, the current file
> name is still valid and not worth churning.
Yes, it is a great realization that the file will have both genbytes
and genzeros in it in the end, and there is no strong reason why it
needs to be renamed.
> 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
> @@ -2,30 +2,28 @@
>
> #include "test-tool.h"
> #include "git-compat-util.h"
> +#include "parse.h"
>
> +/*
> + * Write "count" copies of "byte" to stdout, or an endless stream of them if
> + * "count" is negative.
> + */
> +static int generate_bytes(unsigned char byte, intmax_t count)
> {
> + static char buf[256 * 1024];
> ssize_t n;
>
> + memset(buf, byte, sizeof(buf));
>
> + /* Writing out individual bytes is slow... */
> while (count < 0)
> + if (xwrite(1, buf, ARRAY_SIZE(buf)) < 0)
> die_errno("write error");
A curious infinite loop but that is OK.
> while (count > 0) {
> + n = xwrite(1, buf,
> + count < ARRAY_SIZE(buf)
> + ? count : ARRAY_SIZE(buf));
>
> if (n < 0)
> die_errno("write error");
> @@ -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);
> +}
> +
> +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);
> +}
The callers are so straight-forward.
> diff --git a/t/t0613-reftable-write-options.sh b/t/t0613-reftable-write-options.sh
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
> diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
All conversions of these consumers are so trivially correct.
> diff --git a/t/t9850-shell.sh b/t/t9850-shell.sh
> index 27cc49bbd1..d56edebda7 100755
> --- a/t/t9850-shell.sh
> +++ b/t/t9850-shell.sh
> @@ -30,7 +30,7 @@ test_expect_success 'shell allows interactive command' '
> '
>
> test_expect_success 'shell complains of overlong commands' '
> - test-tool genzeros | tr "\000" "a" |
> + test-tool genbytes a |
> test_must_fail git shell 2>err &&
> test_grep "too long" err
> '
OK, so that's how an infinitely long sequence of characters is used.
Looking good. Let's mark the topic as ready for 'next'.
next prev parent reply other threads:[~2026-11-10 19:31 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 [this message]
2026-11-11 10:54 ` Patrick Steinhardt
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=xmqqo6bwqy9n.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=collin.funk1@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=j6t@kdbg.org \
--cc=krka@spotify.com \
--cc=ps@pks.im \
/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