On Thu, Jan 24, 2019 at 11:27:36AM -0800, Junio C Hamano wrote:

> Jeff King <p...@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

Reply via email to