git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Git List <git@vger.kernel.org>,
	Philippe Blain <levraiphilippeblain@gmail.com>,
	Duy Nguyen <pclouds@gmail.com>
Subject: Re: [PATCH] worktree: teach `repair` to fix multi-directional breakage
Date: Thu, 17 Dec 2020 11:49:21 -0800	[thread overview]
Message-ID: <xmqqwnxgxlfi.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <CAPig+cQT2Cj4i=2kq_svMyKiFmNLxvpa5kG=XNeaT+8UD5238Q@mail.gmail.com> (Eric Sunshine's message of "Thu, 17 Dec 2020 05:22:54 -0500")

Eric Sunshine <sunshine@sunshineco.com> writes:

> We only have the paths making the two-way link between the repository
> and the secondary worktrees. Specifically, the outgoing
> <repo>/worktrees/<id>/gitdir points at /path/to/worktree/.git, and the
> incoming /path/to/worktree/.git points at <repo>/worktrees/<id>.

Yes.

> The inference is intentionally simple-minded. There is no path-based
> inference or other heuristic at play; the entire inference is based
> upon <id>. The worktree's path is specified as an argument. `git
> worktree repair` manually reads the ".git" gitfile at that location
> and, if it is well-formed, extracts the <id>. It then searches for a
> corresponding <id> in <repo>/worktrees/ and,...

That is exactly the point I got confused.  The worktree's path comes
as an argument from the user, so we'd trust it.  And it has ".git"
that is a gitfile that used to point at <repo> but because we are
trying to deal with a situation where both worktree and repo moved,
it cannot be used to learn where <repo> is.  Then, even after
learning what <id> to use, how would we know where to use that <id>
to find <repo>/worktrees/<id>, when the location of <repo> is unknown?

I think the answer is "where the user starts the 'git worktree'
command has to be under control of some repository (perhaps found by
a call to setup_git_directory()), and we'd use that one as <repo>".

Since I did not see that (in hindsight an obvious) piece, I failed
to see how it could possibly work.  But now it is clear.

Thanks.

  reply	other threads:[~2020-12-17 19:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 17:37 [PATCH] worktree: teach `repair` to fix multi-directional breakage Eric Sunshine
2020-12-08 21:47 ` Junio C Hamano
2020-12-17 10:22   ` Eric Sunshine
2020-12-17 19:49     ` Junio C Hamano [this message]
2020-12-17 20:02       ` Eric Sunshine
2020-12-21  8:16 ` [PATCH v2 0/1] teach `worktree repair` to fix two-way linkage Eric Sunshine
2020-12-21  8:16   ` [PATCH v2 1/1] worktree: teach `repair` to fix multi-directional breakage 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=xmqqwnxgxlfi.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=levraiphilippeblain@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=sunshine@sunshineco.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).