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

Re: [PATCH 00/17] refs: unify `refs_for_each_*()` functions

From
Karthik Nayak <karthik.188@gmail.com>
Date
Feb 23, 2026, 09:14 UTC
Message-ID
<CAOLa=ZT6a8wdMgznVr7+ou3mhYKDT_AC3M0s4FCZ-Orjxf+6eQ@mail.gmail.com>
In-Reply-To
<20260220-pks-refs-for-each-unification-v1-0-17170bd99de1@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 38 quoted lines
> Hi,
>
> we currently have 14 different `refs_for_each_*()` functions, with each
> of them doing slightly different things. This makes for a confusing API
> surface, and because the API is not built for extension we have to add a
> new function every now and then to handle another esoteric edge case
> that will ultimately only have at most a handful of callers.
>
> This design isn't really sensible in my opinion, and this patch series
> aims to fix that. Instead of having a dozen different functions, it
> introduces a new `refs_for_each_ref_ext()` function that simply takes an
> options structure as input. From thereon, callers can mix and match the
> parameters that they care about.
>
> The patch series is structured like this:
>
>   - Patches 1 to 5 introduce some preliminary cleanups.
>
>   - Patches 6 to 9 introduce `refs_for_each_ref_ext()` and move
>     more functionality into it. This also fixes a performance bug that
>     we have in one of the implementations.
>
>   - Patch 10 adds some more verification for options that would have
>     caught the bugs in ps/for-each-ref-in-fixes.
>
>   - The remaining patches drop 7 out of 14 functions and replace them
>     with `refs_for_each_ref_ext()`. It results in a bit of churn, so
>     while I think this churn is worth it, I consider these patches to be
>     optional.
>
> The patch series is built on top of 73fd77805f (The 5th batch,
> 2026-02-17) with ps/for-each-ref-in-fixes at 6375a00ef1 (bisect:
> simplify string_list memory handling, 2026-02-19) merged into it.
>
> Thanks!
>
> Patrick
>

I'm really happy with the patches, I have some small nits/questions, but it looks good otherwise.

Thanks, Karthik

[snip]
Previous: Patrick Steinhardt
Message 34 of 34 in “refs: unify `refs_for_each_*()` functions”
  1. 00/17 refs: unify `refs_for_each_*()` functionsPatrick Steinhardt, Feb 20, 2026
  2. 01/17 refs: move `refs_head_ref_namespaced()`Patrick Steinhardt, Feb 20, 2026
  3. Karthik NayakFeb 23, 2026
  4. Patrick SteinhardtFeb 23, 2026
  5. 02/17 refs: move `do_for_each_ref_flags` further upPatrick Steinhardt, Feb 20, 2026
  6. 03/17 refs: rename `do_for_each_ref_flags`Patrick Steinhardt, Feb 20, 2026
  7. 04/17 refs: rename `each_ref_fn`Patrick Steinhardt, Feb 20, 2026
  8. Karthik NayakFeb 23, 2026
  9. 05/17 refs: remove unused `refs_for_each_include_root_ref()`Patrick Steinhardt, Feb 20, 2026
  10. Oswald BuddenhagenFeb 20, 2026
  11. Patrick SteinhardtFeb 20, 2026
  12. 06/17 refs: introduce `refs_for_each_ref_ext`Patrick Steinhardt, Feb 20, 2026
  13. Karthik NayakFeb 23, 2026
  14. 07/17 refs: speed up `refs_for_each_glob_ref_in()`Patrick Steinhardt, Feb 20, 2026
  15. Karthik NayakFeb 23, 2026
  16. Patrick SteinhardtFeb 23, 2026
  17. 08/17 refs: generalize `refs_for_each_namespaced_ref()`Patrick Steinhardt, Feb 20, 2026
  18. Karthik NayakFeb 23, 2026
  19. Patrick SteinhardtFeb 23, 2026
  20. 09/17 refs: generalize `refs_for_each_fullref_in_prefixes()`Patrick Steinhardt, Feb 20, 2026
  21. Karthik NayakFeb 23, 2026
  22. 10/17 refs: improve verification for-each-ref optionsPatrick Steinhardt, Feb 20, 2026
  23. Karthik NayakFeb 23, 2026
  24. 11/17 refs: replace `refs_for_each_ref_in()`Patrick Steinhardt, Feb 20, 2026
  25. Karthik NayakFeb 23, 2026
  26. Patrick SteinhardtFeb 23, 2026
  27. Karthik NayakFeb 23, 2026
  28. 12/17 refs: replace `refs_for_each_rawref()`Patrick Steinhardt, Feb 20, 2026
  29. 13/17 refs: replace `refs_for_each_rawref_in()`Patrick Steinhardt, Feb 20, 2026
  30. 14/17 refs: replace `refs_for_each_glob_ref_in()`Patrick Steinhardt, Feb 20, 2026
  31. 15/17 refs: replace `refs_for_each_glob_ref()`Patrick Steinhardt, Feb 20, 2026
  32. 16/17 refs: replace `refs_for_each_namespaced_ref()`Patrick Steinhardt, Feb 20, 2026
  33. 17/17 refs: replace `refs_for_each_fullref_in()`Patrick Steinhardt, Feb 20, 2026
  34. Karthik NayakFeb 23, 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.