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

Re: [PATCH v3 4/4] for-each-ref: avoid filtering on empty pattern

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 8, 2024, 17:24 UTC
Message-ID
<ZcUOP_rWUwymhe5c@ncase>
In-Reply-To
<xmqq7cjeq43t.fsf@gitster.g>
On Thu, Feb 08, 2024 at 09:04:54AM -0800, Junio C Hamano wrote:
Show 21 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > ```
> > if (!starts_with(iter->ref.refname, "refs/") &&
> >     !(flags & INCLUDE_ROOT_REFS || is_pseudoref(iter->ref.refname)))
> >     continue;
> > ```
> >
> > The problem I have is that it still wouldn't end up surfacing all refs
> > which exist in the ref backend while being computationally more
> > expensive. So the original usecase I had in mind when pitching this
> > topic isn't actually addressed.
> 
> The reftable format, as a database format, may be capable of having
> "refs/heads/master" and "refs/heads/master/1" at the same time, but
> to be used as a ref backend for Git, it must refrain from surfacing
> both at the same time.  I think it is the same deal that it should
> only allow "refs/*", "HEAD", and so called pseudorefs to be stored.
> So INCLUDE_ROOT_REFS should be sufficient as long as the "ref
> creation and update" side is not letting random cruft (e.g.,
> "config") in.  Isn't that sufficient?

That's a different problem from the one I have right now. Let's take the following sequence of commands:

    $ git init repo
    Initialized empty Git repository in /tmp/repo/.git/
    $ git -C repo commit --allow-empty --message message
    [main (root-commit) aa5eec4] message
    $ git -C repo update-ref ref/head/foo HEAD
    $ ls repo/.git/ref/head/foo
    repo/.git/ref/head/foo

Now the fact that you can create "ref/head/foo" is a bug that needs to be fixed, no arguing there. The problem is that rectifying this problem with the "files" backend is easy -- you look into the repo, notice that there's a weird directory, and then "rm -rf" it.

But how do you learn about this ref existing with the "reftable" backend in the first place? You can't without looking at the binary format -- there doesn't exist a single command that would allow you to list all refs unfiltered. But that is very much required in order to learn about misbehaviour and fix it.

As I said -- this is a bug, and I agree that it shouldn't happen. But bugs happen, and especially with the new reftable format I expect them to happen. What I look for in this context is to create the tools to fix problems like this, but `--include-root-refs` doesn't. A flag that unconditionally returns all refs, regardless of whether they have a bad name or not, does address the issue. Think of it of more of a debugging tool.

Spelled out like that it brings me a different idea: maybe I'm just trying to address this in the wrong tool. I plan to introduce ref backend specific fsck checks, so that could be a better place to warn about such refs with bad names. Like this we don't erode the tree-shaped nature by somehow accepting them in some tools, and we make clear that this is indeed something that shouldn't happen.

Show 16 quoted lines
> > I know that in theory, the reftable backend shouldn't contain refs other
> > than "refs/" or pseudo-refs anyway. But regardless of that, I think that
> > formulating this in the form of "root refs" is too restrictive and too
> > much focussed on the "files" backend.
> 
> It is not "focused on".  The ref namespace of Git is tree-shaped,
> period.  The shape may have originated from its first ref backend
> implementation's limitation, but as we gain other backends, we are
> not planning to lift such limitations, are we?  So we may still say
> "when there is a master branch, you cannot have master/1 branch (due
> to D/F conflict)", even if there is no notion of directory or file
> in a backend implementation backed by a databasy file format.  "HEAD"
> and "CHERRY_PICK_HEAD", unlike "refs/tags/v1.0", are at the "root
> level", not only when they are stored in a files backend, but always
> when they are presented to end-users, who can tell that they are not
> inside "refs/".
I agree, and I do not intend to change this.
Patrick
Previous: Junio C HamanoNext: Junio C Hamano
Message 57 of 94 in “for-each-ref: print all refs on empty string pattern”
  1. 0/5 for-each-ref: print all refs on empty string patternKarthik Nayak, Jan 19, 2024
  2. 1/5 refs: expose `is_pseudoref_syntax()`Karthik Nayak, Jan 19, 2024
  3. Junio C HamanoJan 19, 2024
  4. Karthik NayakJan 22, 2024
  5. 2/5 refs: make `is_pseudoref_syntax()` stricterKarthik Nayak, Jan 19, 2024
  6. Junio C HamanoJan 19, 2024
  7. Phillip WoodJan 22, 2024
  8. Junio C HamanoJan 22, 2024
  9. Phillip WoodJan 23, 2024
  10. Karthik NayakJan 23, 2024
  11. phillip.wood123@gmail.comJan 23, 2024
  12. Junio C HamanoJan 23, 2024
  13. Junio C HamanoJan 23, 2024
  14. Patrick SteinhardtJan 23, 2024
  15. Phillip WoodJan 23, 2024
  16. Junio C HamanoJan 23, 2024
  17. Patrick SteinhardtJan 24, 2024
  18. 3/5 refs: extract out `loose_fill_ref_dir_regular_file()`Karthik Nayak, Jan 19, 2024
  19. 4/5 refs: introduce `refs_for_each_all_refs()`Karthik Nayak, Jan 19, 2024
  20. Junio C HamanoJan 19, 2024
  21. Karthik NayakJan 22, 2024
  22. Junio C HamanoJan 22, 2024
  23. 5/5 for-each-ref: avoid filtering on empty patternKarthik Nayak, Jan 19, 2024
  24. 0/4 for-each-ref: print all refs on empty string patternKarthik Nayak, Jan 24, 2024
  25. 1/4 refs: introduce `is_pseudoref()` and `is_headref()`Karthik Nayak, Jan 24, 2024
  26. Junio C HamanoJan 24, 2024
  27. Karthik NayakJan 25, 2024
  28. Junio C HamanoJan 25, 2024
  29. Karthik NayakJan 25, 2024
  30. 2/4 refs: extract out `loose_fill_ref_dir_regular_file()`Karthik Nayak, Jan 24, 2024
  31. 3/4 refs: introduce `refs_for_each_all_refs()`Karthik Nayak, Jan 24, 2024
  32. 4/4 for-each-ref: avoid filtering on empty patternKarthik Nayak, Jan 24, 2024
  33. 0/4 for-each-ref: print all refs on empty string patternKarthik Nayak, Jan 29, 2024
  34. 1/4 refs: introduce `is_pseudoref()` and `is_headref()`Karthik Nayak, Jan 29, 2024
  35. Jeff KingFeb 7, 2024
  36. Karthik NayakFeb 7, 2024
  37. 2/4 refs: extract out `loose_fill_ref_dir_regular_file()`Karthik Nayak, Jan 29, 2024
  38. 3/4 refs: introduce `refs_for_each_all_refs()`Karthik Nayak, Jan 29, 2024
  39. 4/4 for-each-ref: avoid filtering on empty patternKarthik Nayak, Jan 29, 2024
  40. Phillip WoodFeb 5, 2024
  41. Patrick SteinhardtFeb 6, 2024
  42. Phillip WoodFeb 6, 2024
  43. Karthik NayakFeb 6, 2024
  44. Phillip WoodFeb 6, 2024
  45. Karthik NayakFeb 6, 2024
  46. Junio C HamanoFeb 6, 2024
  47. Junio C HamanoFeb 6, 2024
  48. Karthik NayakFeb 6, 2024
  49. Junio C HamanoFeb 6, 2024
  50. Karthik NayakFeb 7, 2024
  51. Junio C HamanoFeb 7, 2024
  52. Karthik NayakFeb 7, 2024
  53. Junio C HamanoFeb 7, 2024
  54. Karthik NayakFeb 7, 2024
  55. Patrick SteinhardtFeb 8, 2024
  56. Junio C HamanoFeb 8, 2024
  57. Patrick SteinhardtFeb 8, 2024
  58. Junio C HamanoFeb 8, 2024
  59. Patrick SteinhardtFeb 9, 2024
  60. Junio C HamanoFeb 9, 2024
  61. Karthik NayakFeb 9, 2024
  62. Patrick SteinhardtFeb 12, 2024
  63. Phillip WoodFeb 8, 2024
  64. Junio C HamanoFeb 8, 2024
  65. Patrick SteinhardtFeb 7, 2024
  66. Junio C HamanoFeb 7, 2024
  67. Junio C HamanoJan 29, 2024
  68. 0/5 for-each-ref: add '--include-root-refs' optionKarthik Nayak, Feb 11, 2024
  69. 1/5 refs: introduce `is_pseudoref()` and `is_headref()`Karthik Nayak, Feb 11, 2024
  70. Patrick SteinhardtFeb 12, 2024
  71. Junio C HamanoFeb 12, 2024
  72. Karthik NayakFeb 13, 2024
  73. Junio C HamanoFeb 13, 2024
  74. Karthik NayakFeb 14, 2024
  75. Junio C HamanoFeb 14, 2024
  76. Karthik NayakFeb 14, 2024
  77. Junio C HamanoFeb 12, 2024
  78. 2/5 refs: extract out `loose_fill_ref_dir_regular_file()`Karthik Nayak, Feb 11, 2024
  79. 3/5 refs: introduce `refs_for_each_include_root_refs()`Karthik Nayak, Feb 11, 2024
  80. 4/5 ref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR'Karthik Nayak, Feb 11, 2024
  81. 5/5 for-each-ref: add new option to include root refsKarthik Nayak, Feb 11, 2024
  82. Patrick SteinhardtFeb 22, 2024
  83. Karthik NayakFeb 22, 2024
  84. Patrick SteinhardtFeb 22, 2024
  85. 0/5 for-each-ref: add '--include-root-refs' optionKarthik Nayak, Feb 23, 2024
  86. 1/5 refs: introduce `is_pseudoref()` and `is_headref()`Karthik Nayak, Feb 23, 2024
  87. 2/5 refs: extract out `loose_fill_ref_dir_regular_file()`Karthik Nayak, Feb 23, 2024
  88. 3/5 refs: introduce `refs_for_each_include_root_refs()`Karthik Nayak, Feb 23, 2024
  89. 4/5 ref-filter: rename 'FILTER_REFS_ALL' to 'FILTER_REFS_REGULAR'Karthik Nayak, Feb 23, 2024
  90. 5/5 for-each-ref: add new option to include root refsKarthik Nayak, Feb 23, 2024
  91. Junio C HamanoFeb 23, 2024
  92. Junio C HamanoFeb 23, 2024
  93. Patrick SteinhardtFeb 27, 2024
  94. Junio C HamanoFeb 27, 2024

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.