]> git.ipfire.org Git - thirdparty/git.git/commit
fsck: mention file path for index errors
authorJeff King <peff@peff.net>
Fri, 24 Feb 2023 08:12:11 +0000 (03:12 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Feb 2023 17:32:23 +0000 (09:32 -0800)
commit592ec63b38ca7e2fb069ce1bf41b47a6f5a4ef8a
tree6305047eb0768f11c1fd78e7272c01cd77d3fe32
parentfb64ca526a7c695aa137c2d2577585ddea5cce28
fsck: mention file path for index errors

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's a bit verbose, but since the point is that you shouldn't see this
normally, we're better to err on the side of more details.

I've also added the index filename to the name used by "fsck
--name-objects", which will show up if we find the object to be missing,
etc. This is bending the rules a little there, as the option claims to
write names that can be fed to rev-parse. But there is no revision
syntax to access the index of another worktree, so the best we can do is
make up something that a human will probably understand.

I did take care to retain the existing ":file" syntax for the current
worktree. So the uglier output should kick in only when it's actually
necessary. See the included tests for examples of both forms.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fsck.c
t/t1450-fsck.sh