Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2023-02-24 11:09:57 +0300
committerJunio C Hamano <gitster@pobox.com>2023-02-24 20:32:23 +0300
commitfb64ca526a7c695aa137c2d2577585ddea5cce28 (patch)
tree3b7a3db7b3d2a7bd1f5be66ecfa73747b4cbe0e2 /builtin/fsck.c
parent8840069a37e69129ed3c2792ddb172557f98e205 (diff)
fsck: check index files in all worktrees
We check the index file for the main worktree, but completely ignore the index files in other worktrees. These should be checked, too, as they are part of the repository state (and in particular, errors in those index files may cause repo-wide operations like "git gc" to complain). Reported-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fsck.c')
-rw-r--r--builtin/fsck.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c
index fa101e0db2..c11cb2a95f 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -984,10 +984,24 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
}
if (keep_cache_objects) {
+ struct worktree **worktrees, **p;
+
verify_index_checksum = 1;
verify_ce_order = 1;
- repo_read_index(the_repository);
- fsck_index(the_repository->index);
+
+ worktrees = get_worktrees();
+ for (p = worktrees; *p; p++) {
+ struct worktree *wt = *p;
+ struct index_state istate =
+ INDEX_STATE_INIT(the_repository);
+
+ if (read_index_from(&istate,
+ worktree_git_path(wt, "index"),
+ get_worktree_git_dir(wt)) > 0)
+ fsck_index(&istate);
+ discard_index(&istate);
+ }
+ free_worktrees(worktrees);
}
check_connectivity();