Re: [PATCH v2 0/3] Ensure unique worktree ids across repositories
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Dec 3, 2024, 00:56 UTC
- Message-ID
- <CAPig+cQHW9=A5ejU5aZ+Wy0uOQsLU_uqUibeYzZs2PXK37Vpbw@mail.gmail.com>
- In-Reply-To
- <xmqqed2pioff.fsf@gitster.g>
On Mon, Dec 2, 2024 at 7:46 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 13 quoted lines
> shejialuo <shejialuo@gmail.com> writes: > > But cross-ref operations between worktrees must explicitly specify the > > worktree id, so I am wondering whether we should allow the user do > > cross-ref operations in the first place: > > > > 1. main worktree symref points to linked worktree ref. > > 2. A linked worktree ref points to another linked worktree ref. > > What is a cross-ref operation? A worktree is either the primary > working tree for a (non-bare) repository, or something added with > "git add worktree" (i.e. whose .git is not the repository but a > link file into the real repository). Are you adding another mode > where a worktree points at another worktree and not the repository?
Unfortunately, I haven't had time lately to follow all these worktree-related changes or discussions, but perhaps shejialuo is referring to the ability, from within one worktree, to mention a ref from another worktree (which is a feature Duy added some time after the initial worktree implementation). Specifically, from the git-worktree man page:
Refs that are per-worktree can still be accessed from another
worktree via two special paths, main-worktree and worktrees. The
former gives access to per-worktree refs of the main worktree,
while the latter to all linked worktrees. For example, main-worktree/HEAD or main-worktree/refs/bisect/good
resolve to the same value as the main worktree’s HEAD and
refs/bisect/good respectively. Similarly, worktrees/foo/HEAD or
worktrees/bar/refs/bisect/bad are the same as
$GIT_COMMON_DIR/worktrees/foo/HEAD and
$GIT_COMMON_DIR/worktrees/bar/refs/bisect/bad.