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

Re: [PATCH 4/3] fsck: check even zero-entry index files

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 27, 2023, 15:58 UTC
Message-ID
<xmqqv8jnt81c.fsf@gitster.g>
In-Reply-To
<Y/vdV4bjorvRYoaR@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> The return value here is actually the number of entries read. So it
> makes sense for add_index_objects_to_pending() to ignore a zero-entry
> index (there is nothing to add). But for fsck, we would still want to
> check any extensions, etc (though presumably it is unlikely to have them
> in an empty index, I don't think it's impossible).
Good thinking.

Not all extensions record what needs to be fed to the reachability machinery for fsck, but resolve-undo wants to record object names that used to be in the directory (at higher stages) when they are removed, so I think it is entirely possible for an index with no entries to have index extensions that fsck needs to pay attention to.

> So we should ignore the return value from read_index_from() entirely.
> This matches the behavior before fb64ca526a, when we ignored the return
> value from repo_read_index().
Good.  Thanks.
Show 24 quoted lines
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> On top of jk/fsck-indices-in-worktrees.
>
>  builtin/fsck.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/fsck.c b/builtin/fsck.c
> index 1b032eebb1..64614b43b2 100644
> --- a/builtin/fsck.c
> +++ b/builtin/fsck.c
> @@ -1007,9 +1007,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
>  			 * while we're examining the index.
>  			 */
>  			path = xstrdup(worktree_git_path(wt, "index"));
> -			if (read_index_from(&istate, path,
> -					    get_worktree_git_dir(wt)) > 0)
> -				fsck_index(&istate, path, wt->is_current);
> +			read_index_from(&istate, path, get_worktree_git_dir(wt));
> +			fsck_index(&istate, path, wt->is_current);
>  			discard_index(&istate);
>  			free(path);
>  		}
Previous: Derrick StoleeNext: Johannes Sixt
Message 18 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.