From: Junio C Hamano Date: Thu, 17 Dec 2020 19:49:21 GMT Subject: Re: [PATCH] worktree: teach `repair` to fix multi-directional breakage Message-ID: In-Reply-To: Eric Sunshine writes: > We only have the paths making the two-way link between the repository > and the secondary worktrees. Specifically, the outgoing > /worktrees//gitdir points at /path/to/worktree/.git, and the > incoming /path/to/worktree/.git points at /worktrees/. Yes. > The inference is intentionally simple-minded. There is no path-based > inference or other heuristic at play; the entire inference is based > upon . 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 . It then searches for a > corresponding in /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 but because we are trying to deal with a situation where both worktree and repo moved, it cannot be used to learn where is. Then, even after learning what to use, how would we know where to use that to find /worktrees/, when the location of 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 ". 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.