git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/2] t: add "test-tool genbytes" to avoid slow tr(1) on macOS

From
Kristofer Karlsson <krka@spotify.com>
Date
Nov 9, 2026, 07:43 UTC
Message-ID
<CAL71e4Mrw2h-D+yKLVE30q-7dnkT31CVsyVmktmS9Wx6Xu6ocQ@mail.gmail.com>
In-Reply-To
<avFvYD5K4SKlveiI@pks.im>
On Mon, 9 Nov 2026 at 07:59, Patrick Steinhardt <ps@pks.im> wrote:
Show 12 quoted lines
>
> Okay. The diff is unfortunately quite useless as we do the file rename
> plus all the changes in a single step. It might've been helpful to split
> this up into:
>
>   1. A rename of the file.
>
>   2. A refactoring of `cmd_genzeros()` to use the write buffer.
>
>   3. A change to introduce `cmd_genbytes()`.
>
> But maybe I'm also overdoing this.

v1 had the rename as a separate commit, and Junio preferred to have it squashed into the change. I do not have a strong opinion either way, so I will wait for a consensus before sending v3.

Show 10 quoted lines
>
> > +     return 0;
> > +}
> > +
> > +static intmax_t parse_count(int argc, const char **argv, int pos)
> > +{
> > +     return pos < argc ? strtoimax(argv[pos], NULL, 0) : -1;
> > +}
>
> We can use `git_parse_signed()` instead.

Good idea. It would also reject invalid counts, which are currently silently treated as 0.

Show 12 quoted lines
> I wonder about the regression in readability though. Maybe that's just
> me, but I don't happen to know all ASCII values by heart, so if I were
> to read this I would now wonder what's so special about 61. And the next
> thing to wonder about is whether this is supposed to encode "=" (decimal
> 61) or "a" (hexadecimal 61), and without reading the code of genbytes I
> would not be able to tell.
>
> So can we maybe make the underpinning logic a bit more intelligent, e.g.
> by accepting "\NNN" or "\xNN" syntax instead of two hex characters? That
> might also make it more extensible going forward if the next developer
> wants to make genbytes take and repeat strings of arbitrary length
> as-is.
That made me look at what the callers actually need:
  callers                     need
  t1007 (4x), t5318           NUL bytes
  t1051 (2x), t1450 (2x),     any byte, only the size matters
    t4141
  t0613, t4205, t7006, t9850  any byte except NUL and newline
  t5300                       three different non-NUL bytes

So none of them needs a particular byte value, and the only special case is NUL, which "genzeros" already covers. For everything else, a plain character is the most readable:

Given that, I am now leaning towards keeping "genzeros" as it is and adding "genbytes <char> [<count>]" for the other callers, i.e. going back to v1 without its last patch (and without a separate rename patch). That avoids inventing a syntax for NUL, keeps the call sites readable, and also leaves the existing "genzeros" callers alone, which addresses Johannes' concern about the churn.

Junio, would that be acceptable, given your suggestion to use hex digits so that NUL does not need special treatment?

The rename is perhaps less important to do if genzeros is kept (though it also gains the genbytes function).

Thanks, Kristofer

Previous: Patrick SteinhardtNext: Kristofer Karlsson via GitGitGadget
Message 31 of 39 in “t: add "test-tool genbytes" to avoid slow tr(1) on macOS”
  1. 0/3 t: add "test-tool genbytes" to avoid slow tr(1) on macOSKristofer Karlsson via GitGitGadget, Nov 7, 2026
  2. 1/3 t/helper: rename test-genzeros.c to test-genbytes.cKristofer Karlsson via GitGitGadget, Nov 7, 2026
  3. Junio C HamanoNov 7, 2026
  4. Junio C HamanoNov 8, 2026
  5. Kristofer KarlssonNov 8, 2026
  6. Junio C HamanoNov 8, 2026
  7. Kristofer KarlssonNov 8, 2026
  8. 2/3 t: add "test-tool genbytes" to avoid slow tr(1) on macOSKristofer Karlsson via GitGitGadget, Nov 7, 2026
  9. Johannes SixtNov 8, 2026
  10. Kristofer KarlssonNov 8, 2026
  11. Johannes SixtNov 8, 2026
  12. Kristofer KarlssonNov 8, 2026
  13. Johannes SixtNov 8, 2026
  14. Johannes SixtNov 9, 2026
  15. Kristofer KarlssonNov 9, 2026
  16. Johannes SixtNov 9, 2026
  17. Collin FunkNov 10, 2026
  18. Kristofer KarlssonNov 10, 2026
  19. Junio C HamanoNov 8, 2026
  20. 3/3 t: replace "test-tool genzeros" with "genbytes NUL"Kristofer Karlsson via GitGitGadget, Nov 7, 2026
  21. Junio C HamanoNov 7, 2026
  22. Kristofer KarlssonNov 8, 2026
  23. Junio C HamanoNov 7, 2026
  24. Kristofer KarlssonNov 8, 2026
  25. 0/2 t: add "test-tool genbytes" to avoid slow tr(1) on macOSKristofer Karlsson via GitGitGadget, Nov 8, 2026
  26. 1/2 t: add "test-tool genbytes" to avoid slow tr(1) on macOSKristofer Karlsson via GitGitGadget, Nov 8, 2026
  27. Junio C HamanoNov 9, 2026
  28. Kristofer KarlssonNov 9, 2026
  29. Junio C HamanoNov 9, 2026
  30. Patrick SteinhardtNov 9, 2026
  31. Kristofer KarlssonNov 9, 2026
  32. 2/2 t: replace "test-tool genzeros" with "genbytes 00"Kristofer Karlsson via GitGitGadget, Nov 8, 2026
  33. t: add "test-tool genbytes" to avoid slow tr(1) on macOSKristofer Karlsson via GitGitGadget, Nov 10, 2026
  34. Junio C HamanoNov 10, 2026
  35. Patrick SteinhardtNov 11, 2026
  36. Junio C HamanoNov 11, 2026
  37. Kristofer KarlssonNov 11, 2026
  38. Junio C HamanoNov 11, 2026
  39. t: add "test-tool genbytes" to avoid slow tr(1) on macOSKristofer Karlsson via GitGitGadget, Nov 11, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.