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

Re: [PATCH] worktree: add per-worktree config files

From
Duy Nguyen <pclouds@gmail.com>
Date
Sep 26, 2018, 15:48 UTC
Message-ID
<CACsJy8Bux0iiOp+zjELM4DuZwiQMA6EDaL0M71Jkp_qPACD8og@mail.gmail.com>
In-Reply-To
<xmqqtvmdnuab.fsf@gitster-ct.c.googlers.com>
On Tue, Sep 25, 2018 at 11:26 PM Junio C Hamano <gitster@pobox.com> wrote:
> Warning: devil's advocate mode on.
Oh good. I need to a good dose of sanity anyway.
Show 6 quoted lines
> Done in either way, this will confuse the users.  What is the reason
> why people are led to think it is a good idea to use multiple
> worktrees, even when they need different settings?  What do they
> want out of "multiple worktrees linked to a single repository" as
> opposed to just a simple "as many clones as necessary"?  Reduced
> disk footprint?

I believe the main selling point of multiple worktrees is sharing refs. You could easily avoid expensive clones with --local, but synchronizing between different clones is not very convenient. Other than that, different worktrees tend to behave like separate clones.

This leaves a gray area where other things should be shared or not. I think the preference (or default mode) is still _not_ shared (*). Sharing more things (besides refs and object database) is just a new opportunity popping up when we implement multiple worktrees. Since multiple worktrees (or clones before its time) are grouped together, sometimes you would like to share common configuration. We could sort of achieve this already with includeIf but again not as convenient.

(*) real life is not that simple. Since refs are shared, including _remotes_ refs, so configuration related to remotes should also be shared, or it will be a maintenance nightmare. Which is why $GIT_DIR/config so far has been shared besides the two exceptions that are core.bare and core.worktree. And I really like to get rid of these exceptions.

> Is there a better way to achieve that without the
> downside of multiple worktrees (e.g. configuration need to be
> uniform)?

Is there a better way to achieve sharing refs between clones? I gave it a minute but couldn't come up with a good answer :(

> > (*) "git config --worktree" points back to "config" file when this
> >     extension is not present so that it works in any setup.
>
> Shouldn't it barf and error out instead?

The intention is a uniform interface/api that works with both single and multiple worktrees configurations. Otherwise in your scripts you would need to write "if single worktree, do this, else do that". If "git config --worktree" works with both, the existing scripts can be audited and updated just a bit, adding "--worktree" where the config should not be shared, and we're done.

> A user who hasn't enabled
> the extension uses --worktree option and misled to believe that the
> setting affects only a single worktree, even though the change is
> made globally---that does not sound like a great end-user experience.

I was talking about a single worktree. But I think here you meant the user has multiple worktrees, but the extension is not enabled. I'm probably not clear in the commit message, but "git config" can detect that the extension has not been enabled, automatically enable it (and move core.bare and core.worktree (if present) to the main worktree's private config), so "git config --worktree" will never share the change.

But perhaps the user should be made aware of this situation and asked to explicitly enable the extension instead? It's certainly a more conservative approach.

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 34 in “worktree: add per-worktree config files”
  1. worktree: add per-worktree config filesNguyễn Thái Ngọc Duy, Sep 23, 2018
  2. Eric SunshineSep 23, 2018
  3. Taylor BlauSep 24, 2018
  4. Duy NguyenSep 25, 2018
  5. Duy NguyenSep 29, 2018
  6. Junio C HamanoSep 25, 2018
  7. Duy NguyenSep 26, 2018
  8. Junio C HamanoSep 26, 2018
  9. Wherefor worktrees?Marc Branchaud, Sep 27, 2018
  10. Duy NguyenSep 27, 2018
  11. Ævar Arnfjörð BjarmasonSep 26, 2018
  12. Duy NguyenSep 27, 2018
  13. Ævar Arnfjörð BjarmasonSep 27, 2018
  14. Duy NguyenSep 27, 2018
  15. Duy NguyenSep 29, 2018
  16. 0/2 Per-worktree config filesNguyễn Thái Ngọc Duy, Sep 29, 2018
  17. 1/2 t1300: extract and use test_cmp_config()Nguyễn Thái Ngọc Duy, Sep 29, 2018
  18. Eric SunshineSep 30, 2018
  19. SZEDER GáborSep 30, 2018
  20. 2/2 worktree: add per-worktree config filesNguyễn Thái Ngọc Duy, Sep 29, 2018
  21. Eric SunshineSep 30, 2018
  22. Duy NguyenSep 30, 2018
  23. Eric SunshineSep 30, 2018
  24. Duy NguyenSep 30, 2018
  25. 0/2 Per-worktree config filesNguyễn Thái Ngọc Duy, Oct 2, 2018
  26. 1/2 t1300: extract and use test_cmp_config()Nguyễn Thái Ngọc Duy, Oct 2, 2018
  27. Eric SunshineOct 3, 2018
  28. 2/2 worktree: add per-worktree config filesNguyễn Thái Ngọc Duy, Oct 2, 2018
  29. 0/2 Per-worktree config filesNguyễn Thái Ngọc Duy, Oct 21, 2018
  30. 1/2 t1300: extract and use test_cmp_config()Nguyễn Thái Ngọc Duy, Oct 21, 2018
  31. 2/2 worktree: add per-worktree config filesNguyễn Thái Ngọc Duy, Oct 21, 2018
  32. Junio C HamanoOct 22, 2018
  33. Duy NguyenOct 22, 2018
  34. Junio C HamanoOct 25, 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.