git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Bug: fsck and repack don't agree when a worktree index extension is "broken"

From
Johannes Sixt <j6t@kdbg.org>
Date
Feb 18, 2023, 09:38 UTC
Message-ID
<c6246ed5-bffc-7af9-1540-4e2071eff5dc@kdbg.org>

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
Next: Jeff King
Message 1 of 19 in “Bug: fsck and repack don't agree when a worktree index extension is "broken"”
  1. Johannes SixtFeb 18, 2023
  2. 0/3 fsck index files from all worktreesJeff King, Feb 24, 2023
  3. 1/3 fsck: factor out index fsckJeff King, Feb 24, 2023
  4. 2/3 fsck: check index files in all worktreesJeff King, Feb 24, 2023
  5. Jeff KingFeb 24, 2023
  6. 3/3 fsck: mention file path for index errorsJeff King, Feb 24, 2023
  7. Eric SunshineMay 11, 2023
  8. Jeff KingMay 11, 2023
  9. Eric SunshineMay 11, 2023
  10. Jeff KingMay 11, 2023
  11. Eric SunshineJun 29, 2023
  12. Junio C HamanoJun 29, 2023
  13. Andreas SchwabJun 1, 2023
  14. Jeff KingJun 1, 2023
  15. Junio C HamanoFeb 24, 2023
  16. 4/3 fsck: check even zero-entry index filesJeff King, Feb 26, 2023
  17. Derrick StoleeFeb 27, 2023
  18. Junio C HamanoFeb 27, 2023
  19. Johannes SixtFeb 26, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.