Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j6t@kdbg.org>
To: Git Mailing List <git@vger.kernel.org>
Subject: Bug: fsck and repack don't agree when a worktree index extension is "broken"
Date: Sat, 18 Feb 2023 10:38:33 +0100	[thread overview]
Message-ID: <c6246ed5-bffc-7af9-1540-4e2071eff5dc@kdbg.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1770 bytes --]

I came into a situation where a worktree index contains an invalid
object ID in an extension. This causes git gc to abort half-way:

$ git gc
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
fatal: unable to read d3e1a3edd7d7851bbf811064090e03475d62fd44
fatal: failed to run repack

However, fsck does not find any problem:

$ git fsck
Checking object directories: 100% (256/256), done.

The problem is an invalid object ID that occurs in a worktree index. If
I copy the index to the main worktree, fsck does find the culprit:

$ cp .git/worktrees/wt/index .git/index
$ git fsck
Checking object directories: 100% (256/256), done.
error: d3e1a3edd7d7851bbf811064090e03475d62fd44: invalid sha1 pointer in
resolve-undo
error: 4b40bf1072d6dfeebc09b11ee4d4f22ca2ce3109: invalid sha1 pointer in
resolve-undo
error: 5a494fd3a2182795e0723300ab1ac75c0797be5b: invalid sha1 pointer in
resolve-undo

and git gc fails in the same way as before (of course).

I see three problems here:

- git fsck should detect the problem (if it really is one) in the
worktree index. It seems that it is just an index extension that is
affected. Perhaps it should be just a warning, not an error.

- If the objects mentioned in the index extension are precious, they
should not have been garbage-collected in earlier rounds of git gc
(which I certainly did at some point).

- I can't git gc the repository now, which is particularly annoying when
auto-gc is attempted after almost every git command. Of course, I know
how to get out of the situation, but it took some time to identify the
worktree index as the culprit. Not something that a beginner would be
able to do easily.

The repository I use for the above commands is attached. I hope vger
doesn't strip it away.

-- Hannes

[-- Attachment #2: git-bug-gc-w-worktree-index.tar.gz --]
[-- Type: application/gzip, Size: 3431 bytes --]

             reply	other threads:[~2023-02-18  9:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-18  9:38 Johannes Sixt [this message]
2023-02-24  8:05 ` [PATCH 0/3] fsck index files from all worktrees Jeff King
2023-02-24  8:07   ` [PATCH 1/3] fsck: factor out index fsck Jeff King
2023-02-24  8:09   ` [PATCH 2/3] fsck: check index files in all worktrees Jeff King
2023-02-24  8:45     ` Jeff King
2023-02-24  8:12   ` [PATCH 3/3] fsck: mention file path for index errors Jeff King
2023-05-11  6:39     ` Eric Sunshine
2023-05-11 16:17       ` Jeff King
2023-05-11 16:28         ` Eric Sunshine
2023-05-11 17:01           ` Jeff King
2023-06-29 18:21             ` Eric Sunshine
2023-06-29 19:37               ` Junio C Hamano
2023-06-01 12:15     ` Andreas Schwab
2023-06-01 14:04       ` Jeff King
2023-02-24 17:30   ` [PATCH 0/3] fsck index files from all worktrees Junio C Hamano
2023-02-26 22:29     ` [PATCH 4/3] fsck: check even zero-entry index files Jeff King
2023-02-27 12:09       ` Derrick Stolee
2023-02-27 15:58       ` Junio C Hamano
2023-02-26 21:49   ` [PATCH 0/3] fsck index files from all worktrees Johannes Sixt

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c6246ed5-bffc-7af9-1540-4e2071eff5dc@kdbg.org \
    --to=j6t@kdbg.org \
    --cc=git@vger.kernel.org \
    /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.
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).