git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: "Ganriel Nützi" <gnuetzi@gmail.com>
Cc: "Git List" <git@vger.kernel.org>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: Re: GIT_DIR output from git worktree list
Date: Tue, 8 Dec 2020 14:27:34 -0500	[thread overview]
Message-ID: <CAPig+cQad_yyVgwQQ-NZyy7SergM-fUMeMAm9RsV4zEqNt9TDg@mail.gmail.com> (raw)
In-Reply-To: <A462326B-505D-4A92-B789-21BB8FE6AA16@gmail.com>

On Mon, Dec 7, 2020 at 2:28 AM Ganriel Nützi <gnuetzi@gmail.com> wrote:
> As of your rational, wouldn‘t it be good anyway to have a file
> „worktree“ inside the .git dir (of the worktree) containing the path
> to the main worktree? So to speak any worktree always has a .git dir
> with a back link to its main worktree (the existence of the git dir
> might pose other problems?)

I'm having trouble understanding your proposal. Secondary worktrees
don't have a .git/ directory; instead they have a "gitfile" named .git
which is just a pointer to the worktree's administrative directory
within the repository (specifically, <repo>/worktrees/<id>/, where
<repo> might be a bare repository or the .git/ directory of the main
worktree).

So a secondary worktree's back-link is a pointer into the repository;
it's not necessarily pointing at the main worktree, as you discovered
and reported in the email which started this thread.

What I was suggesting was that it might be the case that the only way
to solve this would be to store the location of the main worktree
somewhere within <repo> in some file, and then `git worktree list`
would consult that file to learn the location of the main worktree.
This is complicated by the fact that that file would have to be
updated automatically if the main worktree directory is ever moved. It
also needs to be done in such a way that it is easy for other Git
implementations to understand and not trip over.

So, it's certainly possible, but it's something which requires more
thought, and there might be alternate and better solutions I'm
overlooking.

  reply	other threads:[~2020-12-08 20:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 17:30 GIT_DIR output from git worktree list Gabriel Nützi
2020-09-30  5:33 ` Eric Sunshine
2020-09-30  7:34   ` Gabriel Nützi
2020-09-30 20:35     ` Eric Sunshine
2020-12-07  4:34   ` Eric Sunshine
2020-12-07  7:28     ` Ganriel Nützi
2020-12-08 19:27       ` Eric Sunshine [this message]
2020-12-09  9:30         ` Duy Nguyen
2020-12-13  6:07           ` Eric Sunshine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPig+cQad_yyVgwQQ-NZyy7SergM-fUMeMAm9RsV4zEqNt9TDg@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=gnuetzi@gmail.com \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).