Re: [PATCH 3/3] fsck: mention file path for index errors
- From
Jeff King <peff@peff.net>
- Date
- Jun 1, 2023, 14:04 UTC
- Message-ID
- <20230601140436.GB2458601@coredump.intra.peff.net>
- In-Reply-To
- <mvmzg5j8jkk.fsf@suse.de>
On Thu, Jun 01, 2023 at 02:15:39PM +0200, Andreas Schwab wrote:
Show 19 quoted lines
> On Feb 24 2023, Jeff King wrote: > > > If we encounter an error in an index file, we may say something like: > > > > error: 1234abcd: invalid sha1 pointer in resolve-undo > > > > But if you have multiple worktrees, each with its own index, it can be > > very helpful to know which file had the problem. So let's pass that path > > down through the various index-fsck functions and use it where > > appropriate. After this patch you should get something like: > > > > error: 1234abcd: invalid sha1 pointer in resolve-undo of .git/worktrees/wt/index > > That is still suboptimal, because there is no obvious mapping from the > internal worktree name to the directory where it lives (git worktree > list doesn't mention the internal name). If you have several worktrees > with the same base name in different places, the name under > .git/worktrees is just made unique by appending a number. Normally you > would want to change to the affected worktree directory to repair it.
I don't use worktrees all that much, and I never had to repair one of these cases in the real world, but I would have imagined you'd chdir into the affected .git directory to fix things (either by blowing away the index, or by running Git commands inside there).
I don't think it would be too hard to print more information. The caller of fsck_index() has the "struct worktree", which contains more path information. But we'd need to figure out how to present it, as well as which paths to show in fsck_cache_tree(), etc.
So I'd say "patches welcome" if anybody wants to figure out those issues. :)
-Peff