git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Git List" <git@vger.kernel.org>,
	"Henré Botha" <henrebotha@gmail.com>, "Jeff King" <peff@peff.net>
Subject: Re: [PATCH 3/5] worktree: teach "repair" to fix outgoing links to worktrees
Date: Sun, 30 Aug 2020 03:36:38 -0400	[thread overview]
Message-ID: <CAPig+cT-w6LV490MGNyG_ihWkSzdgfnEBrjQCsafjndTRmMgFA@mail.gmail.com> (raw)
In-Reply-To: <xmqqh7soqady.fsf@gitster.c.googlers.com>

On Thu, Aug 27, 2020 at 1:14 PM Junio C Hamano <gitster@pobox.com> wrote:
> Eric Sunshine <sunshine@sunshineco.com> writes:
> > Therefore, teach "git worktree repair" how to repair broken or outdated
> > .git/worktrees/<id>/gitdir files automatically. (For this to work, the
> > command must either be invoked from within the worktree whose gitdir
> > file requires repair, or from within the main or any linked worktree by
> > providing the path of the broken worktree as an argument to "git
> > worktree repair".)
>
> Would git "work" in a corrupt worktree whose gitfile is broken, in
> the sense that it notices that the cwd is the top of the working
> tree of a secondary worktree?

No. For this repair to work, the gitfile in the linked worktree must
be intact; it must be pointing back at the .git/worktrees/<id>
directory so that "git worktree repair" can repair the corresponding
.git/worktrees/<id>/gitdir file.

Making it "work" for the case when both the worktree's gitfile is
broken and .git/worktrees/<id>/gitdir is broken would require an
enhancement like what you mentioned in your review of patch [2/5] in
which the user would manually specify the location of the main
worktree (or repository). That is something which can be added, but I
wanted to keep this initial implementation simple.

> Hmph, if the secondary is _moved_, how would "worktree repair $path"
> would know which <id> the $path corresponds to? Would we just cull
> all the <id> that do not point at working secondary worktrees and
> add the $path as if it were a new one by allocating a new <id>, or
> reusing a randomly chosen <id> that points at a non-existing
> location?

Since this can only work if the linked worktree's gitfile is intact,
and since the content of the gitfile is the path .git/worktrees/<id>,
"git worktree repair" knows the exact <id>, thus the precise
.git/worktrees/<id>/gitdir file to repair. It is deterministic; there
is no guessing about <id>, and there is no creating a new <id>
magically (though I did consider additional repair cases but opted
against them for the initial implementation).

  reply	other threads:[~2020-08-30  7:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-27  8:21 [PATCH 0/5] add "git worktree repair" command Eric Sunshine
2020-08-27  8:21 ` [PATCH 1/5] worktree: add skeleton "repair" command Eric Sunshine
2020-08-27 16:08   ` Junio C Hamano
2020-08-27 19:30     ` Eric Sunshine
2020-08-27  8:21 ` [PATCH 2/5] worktree: teach "repair" to fix worktree back-links to main worktree Eric Sunshine
2020-08-27 17:05   ` Junio C Hamano
2020-08-30  7:20     ` Eric Sunshine
2020-08-27  8:21 ` [PATCH 3/5] worktree: teach "repair" to fix outgoing links to worktrees Eric Sunshine
2020-08-27 17:14   ` Junio C Hamano
2020-08-30  7:36     ` Eric Sunshine [this message]
2020-08-31 19:07       ` Junio C Hamano
2020-08-28  2:15   ` Johannes Schindelin
2020-08-28 16:27     ` Eric Sunshine
2020-08-27  8:21 ` [PATCH 4/5] init: teach --separate-git-dir to repair linked worktrees Eric Sunshine
2020-08-27  8:21 ` [PATCH 5/5] init: make --separate-git-dir work from within linked worktree Eric Sunshine
2020-08-31  6:57 ` [PATCH v2 0/5] add "git worktree repair" command Eric Sunshine
2020-08-31  6:57   ` [PATCH v2 1/5] worktree: add skeleton "repair" command Eric Sunshine
2020-08-31  6:57   ` [PATCH v2 2/5] worktree: teach "repair" to fix worktree back-links to main worktree Eric Sunshine
2020-08-31  6:57   ` [PATCH v2 3/5] worktree: teach "repair" to fix outgoing links to worktrees Eric Sunshine
2020-08-31  6:57   ` [PATCH v2 4/5] init: teach --separate-git-dir to repair linked worktrees Eric Sunshine
2020-08-31  6:58   ` [PATCH v2 5/5] init: make --separate-git-dir work from within linked worktree Eric Sunshine
2020-08-31 18:59   ` [PATCH v2 0/5] add "git worktree repair" command Junio C Hamano

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+cT-w6LV490MGNyG_ihWkSzdgfnEBrjQCsafjndTRmMgFA@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=henrebotha@gmail.com \
    --cc=peff@peff.net \
    /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).