Patrick Steinhardt <ps@xxxxxx> writes: > On Wed, Jan 03, 2024 at 09:59:13AM -0800, Junio C Hamano wrote: >> Patrick Steinhardt <ps@xxxxxx> writes: >> >> >> I think we should tighten things up over time. First by teaching >> >> the ref backend that anything that is not a pseudoref, HEAD or a >> >> proper ref (one item of whose definition is "lives under refs/ >> >> hierarchy) should not resolve_ref() successfully. That should >> >> correctly fail things like >> >> >> >> $ git rev-parse worktrees/$name/bisect/bad >> >> $ git update-ref foo/bar HEAD >> > ... >> > Yeah, agreed, that's something we should do. I do wonder whether this >> > will break existing usecases, but in any case I'd rather consider it an >> > accident that it is possible to write (and read) such refs in the first >> > place. >> >> Unfortunately, the worktrees/$name/refs/bisect/bad and its friends >> are documented in "git worktree" and the refs.c layer is aware of >> the "main-worktree/" and "worktrees/" hierarchy, so while I still >> think it is a good long-term direction to make it impossible to >> create random refs like "foo/bar" and "resf/heads/master" via the >> commands like "git update-ref", we cannot limit ourselves only to >> "refs/" hierarchy. > > Ah, I first wanted to point this out, but then noticed that you didn't > include the "refs/" prefix in "worktrees/$name/bisect/bad" and thought > this was intentional. But yes, per-worktree refs need to stay supported, > weird as they may be. > > Patrick Thanks all for the discussion, I'll try to summarize the path forward as per my understanding. 1. We want to introduce a way to output all refs. This includes refs under "refs/", pseudo refs, HEAD, and any other ref like objects under $GIT_DIR. The reasoning being that users are allowed currently to create refs without any directory restrictions. So with the upcoming reftable backend, it becomes important to provide a utility to print all the refs held in the reftable. Ideally we want to restrict such ref's from being created but for the time being, since thats allowed, we should also provide the utility to print such refs. 2. In the files backend, this would involve iterating through the $GIT_DIR and finding all ref-like objects and printing them. 3. To expose this to the user, we could do something like $ git for-each-ref "" Which is a natural extension of the current syntax, where the empty string would imply that we do not filter to the "refs/" directory. It is still not clear whether we should support "worktrees". Any corrections here?
Attachment:
signature.asc
Description: PGP signature