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

Re: [PATCH 2/8] Add a place for (not) sharing stuff between worktrees

From
Duy Nguyen <pclouds@gmail.com>
Date
Sep 25, 2018, 16:55 UTC
Message-ID
<CACsJy8BRv1wb7urzriaj9AceZh-Ot1Tsb2w9rExRXkoHFn7_hw@mail.gmail.com>
In-Reply-To
<CAGZ79kZw8-BiW5VE_YN5X2E07FeMA=XtHpjcUoSFtWNRu44fAQ@mail.gmail.com>
On Tue, Sep 25, 2018 at 6:24 PM Stefan Beller <sbeller@google.com> wrote:
Show 18 quoted lines
> > > That sounds dangerous to me. There is already a concept of
> > > local and remote-tracking branches. So I would think that local
> > > may soon become an overused word, (just like "index" today or
> > > "recursive" to a lesser extend).
> > >
> > > Could this special area be more explicit?
> > > (refs/worktree-local/ ? or after peeking at the docs below
> > > refs/un-common/ ?)
> >
> > refs/un-common sounds really "uncommon" :D. If refs/local is bad, I
> > guess we could go with either refs/worktree-local, refs/worktree,
> > refs/private, refs/per-worktree... My vote is on refs/worktree. I
>
> refs/worktree sounds good to me (I do not object), but I am not
> overly enthused either, as when I think further worktrees and
> submodules are both features with a very similar nature in that
> they touch a lot of core concepts in Git, but seem to be a niche
> feature for the masses for now.

I think the similarity is partly because submodule feature also has to manage worktrees. My view is at some point, this "git worktree" would be good enough that it can handle submodules as well (for the worktree part only of course)

Show 6 quoted lines
> For example I could think of submodules following this addressing
> mode as well: submodule/<path>/master sounds similar to the
> originally proposed worktree/<name>/<branch> convention.
> For now it is not quite clear to me why you would want to have
> access to the submodule refs in the superproject, but maybe
> the use case will come later.

Yeah. In theory we could "mount" the submodule ref store to a superproject's ref store. I think it may be needed just for the same reason it's needed for worktree: error reporting. If you peek into a submodule and say "HEAD has an error", the user will get confused whether it's superproject's HEAD or a submodule's HEAD.

> And with that said, I wonder if the "local" part should be feature agnostic,
> or if we want to be "local" for worktrees, "local" for remotes, "local"
> for submodules (i.e. our own refs vs submodule refs).
You lost me here.
Show 8 quoted lines
>
> > think as long as the word "worktree" is in there, people would notice
> > the difference.
>
> That makes sense. But is refs/worktree shared or local? It's not quite
> obvious to me, as I could have refs/worktree/<worktree-name>/master
> instead when it is shared, so I tend to favor refs/local-worktree/ a bit
> more, but that is more typing. :/

OK I think mixing the two patches will different purposes messes you (or me) up ;-)

refs/worktrees/xxx (and refs/main/xxx) are about visibility from other worktrees. Or like Eric put it, they are simply aliases. These refs are not shared because if they are, you can already see them without new "ref mount points" like this.

refs/worktree (previously refs/local) is also per-worktree but it's specifically because you can't have per-worktree inside "refs/" (the only exception so far is refs/bisect which is hard coded). You can have refs outside "refs/" (like HEAD or FETCH_HEAD) and they will not be shared, but they cannot be iterated while those inside refs/ can be. This is more about deciding what to share and I believe is really worktree-specific and only matters to _current_ worktree.

Since refs/worktree is per-worktree, you can also view them from a different worktree via refs/worktrees/. E.g. if you have refs/worktree/foo then another worktree can see it via refs/worktrees/xxx/refs/worktree/foo (besides pseudo refs like refs/worktrees/xxx/HEAD)

Show 12 quoted lines
> As we grow the worktree feature, do we ever expect the need to
> reference the current worktree?
>
> For example when there is a ref "test" that could be unique per
> repo and in the common area, so refs/heads/test would describe
> it and "test" would get there in DWIM mode.
>
> But then I could also delete the common ref and recreate a "test"
> ref in worktree A, in worktree B however DWIMming "test" could still
> refer to A's "test" as it is unique (so far) in the repository.
> And maybe I would want to check if test exists locally, so I'd
> want to ask for "self/test" (with "self" == "B" as that is my cwd).

You probably lost me again. In theory we must be able to detect ambiguity and stop DWIMing. If you want to be ambiguity-free, you specify full ref name, starting with "refs/" which should function like "self/" because worktree design so far is always about the current worktree's view.

-- 
Duy
Previous: Stefan BellerNext: Stefan Beller
Message 8 of 60 in “fix per-worktree ref iteration in fsck/reflog expire”
  1. 0/8 fix per-worktree ref iteration in fsck/reflog expireNguyễn Thái Ngọc Duy, Sep 22, 2018
  2. 1/8 refs.c: indent with tabs, not spacesNguyễn Thái Ngọc Duy, Sep 22, 2018
  3. 2/8 Add a place for (not) sharing stuff between worktreesNguyễn Thái Ngọc Duy, Sep 22, 2018
  4. Eric SunshineSep 23, 2018
  5. Stefan BellerSep 25, 2018
  6. Duy NguyenSep 25, 2018
  7. Stefan BellerSep 25, 2018
  8. Duy NguyenSep 25, 2018
  9. Stefan BellerSep 25, 2018
  10. 3/8 refs: new ref types to make per-worktree refs visible to all worktreesNguyễn Thái Ngọc Duy, Sep 22, 2018
  11. Eric SunshineSep 23, 2018
  12. Duy NguyenSep 23, 2018
  13. Stefan BellerSep 25, 2018
  14. Duy NguyenSep 25, 2018
  15. Stefan BellerSep 25, 2018
  16. Junio C HamanoSep 25, 2018
  17. Duy NguyenSep 29, 2018
  18. Junio C HamanoOct 6, 2018
  19. 4/8 revision.c: correct a parameter nameNguyễn Thái Ngọc Duy, Sep 22, 2018
  20. 5/8 revision.c: better error reporting on ref from different worktreesNguyễn Thái Ngọc Duy, Sep 22, 2018
  21. Eric SunshineSep 23, 2018
  22. Duy NguyenSep 23, 2018
  23. 7/8 fsck: check HEAD and reflog from other worktreesNguyễn Thái Ngọc Duy, Sep 22, 2018
  24. Eric SunshineSep 23, 2018
  25. Duy NguyenSep 29, 2018
  26. 8/8 reflog expire: cover reflog from all worktreesNguyễn Thái Ngọc Duy, Sep 22, 2018
  27. 6/8 fsck: Move fsck_head_link() to get_default_heads() to avoid some globalsNguyễn Thái Ngọc Duy, Sep 22, 2018
  28. 0/8 fix per-worktree ref iteration in fsck/reflog expireNguyễn Thái Ngọc Duy, Sep 29, 2018
  29. 2/8 Add a place for (not) sharing stuff between worktreesNguyễn Thái Ngọc Duy, Sep 29, 2018
  30. 1/8 refs.c: indent with tabs, not spacesNguyễn Thái Ngọc Duy, Sep 29, 2018
  31. 3/8 refs: new ref types to make per-worktree refs visible to all worktreesNguyễn Thái Ngọc Duy, Sep 29, 2018
  32. Eric SunshineSep 30, 2018
  33. Junio C HamanoOct 7, 2018
  34. 4/8 revision.c: correct a parameter nameNguyễn Thái Ngọc Duy, Sep 29, 2018
  35. 5/8 revision.c: better error reporting on ref from different worktreesNguyễn Thái Ngọc Duy, Sep 29, 2018
  36. Eric SunshineSep 30, 2018
  37. 7/8 fsck: check HEAD and reflog from other worktreesNguyễn Thái Ngọc Duy, Sep 29, 2018
  38. 6/8 fsck: Move fsck_head_link() to get_default_heads() to avoid some globalsNguyễn Thái Ngọc Duy, Sep 29, 2018
  39. 8/8 reflog expire: cover reflog from all worktreesNguyễn Thái Ngọc Duy, Sep 29, 2018
  40. Eric SunshineSep 30, 2018
  41. Duy NguyenOct 2, 2018
  42. Eric SunshineOct 3, 2018
  43. 0/8 fix per-worktree ref iteration in fsck/reflog expireNguyễn Thái Ngọc Duy, Oct 21, 2018
  44. 1/8 refs.c: indent with tabs, not spacesNguyễn Thái Ngọc Duy, Oct 21, 2018
  45. 2/8 Add a place for (not) sharing stuff between worktreesNguyễn Thái Ngọc Duy, Oct 21, 2018
  46. Junio C HamanoOct 22, 2018
  47. Duy NguyenOct 29, 2018
  48. SZEDER GáborOct 22, 2018
  49. 3/8 refs: new ref types to make per-worktree refs visible to all worktreesNguyễn Thái Ngọc Duy, Oct 21, 2018
  50. Ævar Arnfjörð BjarmasonNov 24, 2018
  51. Junio C HamanoNov 25, 2018
  52. files-backend.c: fix build error on SolarisNguyễn Thái Ngọc Duy, Nov 25, 2018
  53. Carlo ArenasNov 25, 2018
  54. Duy NguyenNov 25, 2018
  55. Junio C HamanoNov 26, 2018
  56. 4/8 revision.c: correct a parameter nameNguyễn Thái Ngọc Duy, Oct 21, 2018
  57. 5/8 revision.c: better error reporting on ref from different worktreesNguyễn Thái Ngọc Duy, Oct 21, 2018
  58. 6/8 fsck: Move fsck_head_link() to get_default_heads() to avoid some globalsNguyễn Thái Ngọc Duy, Oct 21, 2018
  59. 7/8 fsck: check HEAD and reflog from other worktreesNguyễn Thái Ngọc Duy, Oct 21, 2018
  60. 8/8 reflog expire: cover reflog from all worktreesNguyễn Thái Ngọc Duy, Oct 21, 2018

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.