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

RE: Bug report - Can create worktrees from bare repo / such worktrees can fool is_bare_repository()

From
rsbecker@nexbridge.com <rsbecker@nexbridge.com>
Date
Dec 19, 2021, 21:32 UTC
Message-ID
<003f01d7f51f$f7bb0860$e7311920$@nexbridge.com>
In-Reply-To
<CABceR4YVd4remACJkxwSCTSYB2v3Zn1BsjKHbzeve8uHiZv1pA@mail.gmail.com>
On December 19, 2021 3:47 PM, Sean Allred wrote:
Show 41 quoted lines
> To: Eric Sunshine <sunshine@sunshineco.com>
> Cc: git@vger.kernel.org
> Subject: Re: Bug report - Can create worktrees from bare repo / such
> worktrees can fool is_bare_repository()
> 
> > However, you missed the step (discussed in [1]) in which it is your
> > responsibility to move the `core.bare=true` setting from
> > git.git/config to git.git/worktree.config manually after setting
> > `extensions.worktreeconfig=true`.
> 
> Ahh, that makes sense!  I did notice the `core.bare` setting being respected
> in source and figured this had a part to play (which is why I included git-config
> output).
> 
> I think then that I was overzealous in trying to MWE-ify the issue: as I noted, I
> found this issue when I was trying to perform a sparse-checkout within the
> worktree.  To memory (I don't have my work system at the moment and
> don't have its `history`), I think it went something like this:
> 
>     git worktree add --no-checkout ../next && cd ../next
>     git sparse-checkout init --cone # auto-created a worktree config
>     git sparse-checkout set t
> 
> I think either the git-sparse-checkout-set command (or the git-checkout I ran
> after) would fail complaining that I was not in a worktree.  Based on the
> above, it sounds like `init` is creating the worktree-specific config, but is not
> overriding `core.bare` in that config.  Would a patch to take this step this
> automatically be well-received?  I see two options for when to set
> `core.bare=false` in worktree-specific config:
> 
>   1. At git-worktree-add: This is probably the earliest time which
>      makes sense, but may be over-reach.  I'm not up-to-speed on how
>      worktree-specific configs are generally considered on this list.
>      If I were implementing a workaround, though, this is probably
>      where I'd make it.
> 
>   2. At git-sparse-checkout-init: This is where the problem begins to
>      have an effect, so this might also make sense.
> 
> I'm glad to learn about bare repositories + worktrees being a supported use-
> case :-)

Fair enough, but what about the comparison code where is_bare_repository_cfg is compared with 1 (it is a boolean and sometimes set to -1). This would not generally pass a code review. -Randall

Previous: Sean AllredNext: Sean Allred
Message 7 of 19 in “Bug report - Can create worktrees from bare repo / such worktrees can fool is_bare_repository()”
  1. Sean AllredDec 18, 2021
  2. rsbecker@nexbridge.comDec 18, 2021
  3. Sean AllredDec 18, 2021
  4. rsbecker@nexbridge.comDec 18, 2021
  5. Eric SunshineDec 19, 2021
  6. Sean AllredDec 19, 2021
  7. rsbecker@nexbridge.comDec 19, 2021
  8. Sean AllredDec 19, 2021
  9. rsbecker@nexbridge.comDec 19, 2021
  10. Eric SunshineDec 19, 2021
  11. Eric SunshineDec 19, 2021
  12. rsbecker@nexbridge.comDec 19, 2021
  13. Eric SunshineDec 20, 2021
  14. Eric SunshineDec 20, 2021
  15. Derrick StoleeDec 20, 2021
  16. Eric SunshineDec 20, 2021
  17. Derrick StoleeDec 20, 2021
  18. Eric SunshineDec 20, 2021
  19. Junio C HamanoDec 20, 2021

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.