Re: [PATCH v6 1/3] ref-filter: add worktreepath atom
- From
Jeff King <peff@peff.net>
- Date
- Jan 24, 2019, 19:34 UTC
- Message-ID
- <20190124193417.GA14896@sigill.intra.peff.net>
- In-Reply-To
- <xmqqh8dxj1p3.fsf@gitster-ct.c.googlers.com>
On Thu, Jan 24, 2019 at 11:27:36AM -0800, Junio C Hamano wrote:
Show 10 quoted lines
> Jeff King <peff@peff.net> writes: > > > If anything, I'd suggest going in the opposite direction, and teaching > > the worktree code a function for looking up a working tree by ref. And > > then it can handle its own cache to implement that reverse-mapping > > efficiently. > > Yeah, that's a thought. Then "give me a worktree that checks out > this ref" can be asked outside the context of for-each-ref and > friends, which is a big plus.
One tricky thing is that we do not store a list of "struct worktree", but rather generate it on the fly when get_worktrees() is called.
So having an API to ask for one ref's worktree at a time is slightly awkward. It's only by having (and caching) this full list in ref-filter.c that we can easily make the reverse-indexed hashmap.
-Peff