git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git init --separate-git-dir doesn't play nice with linked working trees
@ 2020-06-18 16:48 Henré Botha
  2020-06-25  6:16 ` Eric Sunshine
  2020-08-27  8:26 ` Eric Sunshine
  0 siblings, 2 replies; 3+ messages in thread
From: Henré Botha @ 2020-06-18 16:48 UTC (permalink / raw)
  To: git

I have identified two potential problems when using git init
--separate-git-dir with a repo that has linked working trees (created
using git worktree add).
1. Moving the gitdir of a main working tree doesn't inform linked
working trees that their gitdir has moved. It seems to me that if I do
cd main-worktree && git init --separate-git-dir=.git_repo, the git
init command should go to all the linked working trees and change
their Git links to point at main-worktree/.git_repo. But perhaps
there's some use case I'm not aware of where you'd want to change only
the gitdir path of the main working tree, and not those of linked
working trees.
2. Attempting to move the gitdir of a linked working tree breaks the
linked working tree entirely.
It seems to me that if I do cd linked-worktree && git init
--separate-git-dir=.git_repo, it should fail, or warn, or do something
other than break the linked working tree. (I note that
linked-worktree/{.git,.git_repo/commondir,.git_repo/gitdir} all point
at the wrong thing after this operation; manually fixing them restores
functionality, though it loses the link to the main working tree.)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git init --separate-git-dir doesn't play nice with linked working trees
  2020-06-18 16:48 git init --separate-git-dir doesn't play nice with linked working trees Henré Botha
@ 2020-06-25  6:16 ` Eric Sunshine
  2020-08-27  8:26 ` Eric Sunshine
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Sunshine @ 2020-06-25  6:16 UTC (permalink / raw)
  To: Henré Botha; +Cc: Git List

On Thu, Jun 18, 2020 at 12:48 PM Henré Botha <henrebotha@gmail.com> wrote:
> I have identified two potential problems when using git init
> --separate-git-dir with a repo that has linked working trees (created
> using git worktree add).
>
> 1. Moving the gitdir of a main working tree doesn't inform linked
> working trees that their gitdir has moved. It seems to me that if I do
> cd main-worktree && git init --separate-git-dir=.git_repo, the git
> init command should go to all the linked working trees and change
> their Git links to point at main-worktree/.git_repo. But perhaps
> there's some use case I'm not aware of where you'd want to change only
> the gitdir path of the main working tree, and not those of linked
> working trees.

This is almost certainly an oversight in the implementation; the
--separate-git-dir option wasn't mentioned during development of
git-worktree as far as I recall.

As this relocation of the repository is entirely under Git's control
(as opposed to the user mucking around as with "mv .git ../foo), it
does indeed seem reasonable that --separate-git-dir should update the
worktree meta-information files. As far as I know, there is no
existing machinery to perform this sort of update, though, so it would
have to be implemented from scratch.

> 2. Attempting to move the gitdir of a linked working tree breaks the
> linked working tree entirely.
> It seems to me that if I do cd linked-worktree && git init
> --separate-git-dir=.git_repo, it should fail, or warn, or do something
> other than break the linked working tree. (I note that
> linked-worktree/{.git,.git_repo/commondir,.git_repo/gitdir} all point
> at the wrong thing after this operation; manually fixing them restores
> functionality, though it loses the link to the main working tree.)

Again, an oversight; --separate-git-dir wasn't on anyone's mind during
development. This is just utterly broken, as far as I can tell; it
doesn't move the repository out of the main worktree to the new
location but instead seems to make a copy of it (minus the
.git/worktrees directory) and drops entries from the original
.git/worktrees directory, thus breaking everything. I suppose it could
error out, though friendlier would be for it to behave correctly.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git init --separate-git-dir doesn't play nice with linked working trees
  2020-06-18 16:48 git init --separate-git-dir doesn't play nice with linked working trees Henré Botha
  2020-06-25  6:16 ` Eric Sunshine
@ 2020-08-27  8:26 ` Eric Sunshine
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Sunshine @ 2020-08-27  8:26 UTC (permalink / raw)
  To: Henré Botha; +Cc: Git List

On Thu, Jun 18, 2020 at 12:48 PM Henré Botha <henrebotha@gmail.com> wrote:
> I have identified two potential problems when using git init
> --separate-git-dir with a repo that has linked working trees (created
> using git worktree add).

A patch series fixing these problems has been posted[1].

[1]: https://lore.kernel.org/git/20200827082129.56149-1-sunshine@sunshineco.com/T/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-27  8:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18 16:48 git init --separate-git-dir doesn't play nice with linked working trees Henré Botha
2020-06-25  6:16 ` Eric Sunshine
2020-08-27  8:26 ` Eric Sunshine

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).