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

Re: [PATCH v2 2/4] pack-bitmap: fix bug with exact ref match in "pack.preferBitmapTips"

From
Taylor Blau <me@ttaylorr.com>
Date
Feb 2, 2026, 02:13 UTC
Message-ID
<aYAIVw5UMQeP3Ilr@nand.local>
In-Reply-To
<20260130-b4-pks-fix-for-each-ref-in-misuse-v2-2-0449b198a681@pks.im>
On Fri, Jan 30, 2026 at 02:27:43PM +0100, Patrick Steinhardt wrote:
Show 15 quoted lines
> [...] There are two possible ways to fix this issue:
>
>   - We can fix the bug by using `refs_for_each_fullref_in()` instead,
>     which does not strip the prefix at all. Consequently, we would now
>     start to accept all references that start with the configured
>     prefix, including exact matches. So if we had "refs/heads/main", we
>     would both match "refs/heads/main" and "refs/heads/main-branch".
>
>   - Or we can fix the bug by appending a slash to the prefix if it
>     doesn't already have one. This would mean that we only match
>     ref hierarchies that start with this prefix.
>
> The first fix leaves the user with strictly _more_ configuration
> options: they can have prefix matches by not appending a slash to the
> configuration, and they can have ref hierarchy matches by appending one.

I would definitely like to err on the side of more flexible configuration options, but I am still concerned that this change would lead to somewhat surprising behavior.

A couple of thoughts:
 - Like I mentioned in the earlier round, 10e8a9352bc (refs.c: stop
   matching non-directory prefixes in exclude patterns, 2025-03-06)
   takes the opposite approach as what is being proposed here. I worry
   that users will find the difference in behavior between
   pack.preferBitmapTips and for-each-ref's --exclude patterns to be
   confusing.
 - If a user wants to list all references that start with
   "refs/heads/ma" in the string prefix sense (that is, matching
   "refs/heads/ma", "refs/heads/main", "refs/heads/master" and so on),
   then they would do
     $ git for-each-ref 'refs/heads/ma*'
   , not 'refs/heads/ma'. In fact, enumerating 'refs/heads/ma' when
   there exist references "refs/heads/ma/foo", "refs/heads/ma/bar",
   etc., for-each-ref will output those three references (but only
   "refs/heads/ma" itself if it exists).

I suppose there is an argument to be made that we are dealing with "patterns" vs. "prefixes" here, but TBH I am not sure that is a distinction that is well-understood by users (nor should we expect it to be).

The original intent of this configuration was that "suffix" in this context meant directory suffix or exact match, not string suffix. The implementation does not match that intent, but I think there is enough ambiguity here that I wouldn't consider the change I'm suggesting to be a breaking one.

Overall, I think interpreting the pack.preferBitmapTips configuration as a reference pattern gives the user both (a) more flexibility in which references to match, and (b) does so in a way that is consistent with 10e8a9352bc and the existing behavior of for-each-ref.

Thanks, Taylor

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 22 of 42 in “Fix misuse of `refs_for_each_ref_in()`”
  1. 0/3 Fix misuse of `refs_for_each_ref_in()`Patrick Steinhardt, Jan 28, 2026
  2. 1/3 pack-bitmap: deduplicate logic to iterate over preferred bitmap tipsPatrick Steinhardt, Jan 28, 2026
  3. Karthik NayakJan 28, 2026
  4. Taylor BlauJan 29, 2026
  5. Junio C HamanoJan 29, 2026
  6. Patrick SteinhardtJan 30, 2026
  7. 2/3 pack-bitmap: fix bug with exact ref match in "pack.preferBitmapTips"Patrick Steinhardt, Jan 28, 2026
  8. Karthik NayakJan 28, 2026
  9. Taylor BlauJan 29, 2026
  10. Junio C HamanoJan 29, 2026
  11. Taylor BlauJan 29, 2026
  12. Junio C HamanoJan 29, 2026
  13. Patrick SteinhardtJan 30, 2026
  14. 3/3 bisect: fix misuse of `refs_for_each_ref_in()`Patrick Steinhardt, Jan 28, 2026
  15. Jeff KingJan 29, 2026
  16. Junio C HamanoJan 29, 2026
  17. Patrick SteinhardtJan 30, 2026
  18. Karthik NayakJan 28, 2026
  19. 0/4 Fix misuse of `refs_for_each_ref_in()`Patrick Steinhardt, Jan 30, 2026
  20. 1/4 pack-bitmap: deduplicate logic to iterate over preferred bitmap tipsPatrick Steinhardt, Jan 30, 2026
  21. 2/4 pack-bitmap: fix bug with exact ref match in "pack.preferBitmapTips"Patrick Steinhardt, Jan 30, 2026
  22. Taylor BlauFeb 2, 2026
  23. Patrick SteinhardtFeb 6, 2026
  24. 3/4 bisect: fix misuse of `refs_for_each_ref_in()`Patrick Steinhardt, Jan 30, 2026
  25. 4/4 bisect: simplify string_list memory handlingPatrick Steinhardt, Jan 30, 2026
  26. Junio C HamanoJan 30, 2026
  27. Taylor BlauFeb 2, 2026
  28. 0/4 Fix misuse of `refs_for_each_ref_in()`Patrick Steinhardt, Feb 6, 2026
  29. 1/4 pack-bitmap: deduplicate logic to iterate over preferred bitmap tipsPatrick Steinhardt, Feb 6, 2026
  30. 2/4 pack-bitmap: fix bug with exact ref match in "pack.preferBitmapTips"Patrick Steinhardt, Feb 6, 2026
  31. Junio C HamanoFeb 6, 2026
  32. 3/4 bisect: fix misuse of `refs_for_each_ref_in()`Patrick Steinhardt, Feb 6, 2026
  33. 4/4 bisect: simplify string_list memory handlingPatrick Steinhardt, Feb 6, 2026
  34. Taylor BlauFeb 18, 2026
  35. Junio C HamanoFeb 19, 2026
  36. 0/4 Fix misuse of `refs_for_each_ref_in()`Patrick Steinhardt, Feb 19, 2026
  37. 1/4 pack-bitmap: deduplicate logic to iterate over preferred bitmap tipsPatrick Steinhardt, Feb 19, 2026
  38. 2/4 pack-bitmap: fix bug with exact ref match in "pack.preferBitmapTips"Patrick Steinhardt, Feb 19, 2026
  39. 3/4 bisect: fix misuse of `refs_for_each_ref_in()`Patrick Steinhardt, Feb 19, 2026
  40. 4/4 bisect: simplify string_list memory handlingPatrick Steinhardt, Feb 19, 2026
  41. Junio C HamanoFeb 26, 2026
  42. Junio C HamanoFeb 26, 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.