git/builtin
Derrick Stolee 756f1bcd29 fsck: verify checksums of all .bitmap files
If a filesystem-level corruption occurs in a .bitmap file, Git can react
poorly. This could take the form of a run-time error due to failing to
parse an EWAH bitmap or be more subtle such as returning the wrong set
of objects to a fetch or clone.

A natural first response to either of these kinds of errors is to run
'git fsck' to see if any files are corrupt. This currently ignores all
.bitmap files.

Add checks to 'git fsck' for all .bitmap files that are currently
associated with a multi-pack-index or pack file. Verify their checksums
using the hashfile API.

We iterate through all multi-pack-indexes and pack-files to be sure to
check all .bitmap files, not just the one that would be read by the
process. For example, a multi-pack-index bitmap overrules a pack-bitmap.
However, if the multi-pack-index is removed, the pack-bitmap may be
selected instead. Be thorough to include every file that could become
active in such a way. This includes checking files in alternates.

There is potential that we could extend this effort to check the
structure of the reachability bitmaps themselves, but it is very
expensive to do so. At minimum, it's as expensive as generating the
bitmaps in the first place, and that's assuming that we don't use the
trivial algorithm of verifying each bitmap individually. The trivial
algorithm will result in quadratic behavior (number of objects times
number of bitmapped commits) while the bitmap building operation
constructs a lattice of commits to build bitmaps incrementally and then
generate the final bitmaps from a subset of those commits.

If we were to extend 'git fsck' to check .bitmap file contents more
closely like this, then we would likely want to hide it behind an option
that signals the user is more willing to do expensive operations such as
this.

For testing, set up a repository with a pack-bitmap _and_ a
multi-pack-index bitmap. This requires some file movement to avoid
deleting the pack-bitmap during the repack that creates the
multi-pack-index bitmap. We can then verify that 'git fsck' is checking
all files, not just the "active" bitmap.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2023-05-02 08:48:22 -07:00
..
add.c editor: move editor-related functions and declarations into common file 2023-04-11 08:52:10 -07:00
am.c pager.h: move declarations for pager.c functions from cache.h 2023-04-11 08:52:10 -07:00
annotate.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
apply.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
archive.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
bisect.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
blame.c pager.h: move declarations for pager.c functions from cache.h 2023-04-11 08:52:10 -07:00
branch.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
bugreport.c editor: move editor-related functions and declarations into common file 2023-04-11 08:52:10 -07:00
bundle.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
cat-file.c object-file.h: move declarations for object-file.c functions from cache.h 2023-04-11 08:52:10 -07:00
check-attr.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
check-ignore.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
check-mailmap.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
check-ref-format.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
checkout--worker.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
checkout-index.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
checkout.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
clean.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
clone.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
column.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
commit-graph.c treewide: be explicit about dependence on trace.h & trace2.h 2023-04-11 08:52:08 -07:00
commit-tree.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
commit.c editor: move editor-related functions and declarations into common file 2023-04-11 08:52:10 -07:00
config.c editor: move editor-related functions and declarations into common file 2023-04-11 08:52:10 -07:00
count-objects.c environment.h: move declarations for environment.c functions from cache.h 2023-03-21 10:56:53 -07:00
credential-cache--daemon.c object-file.h: move declarations for object-file.c functions from cache.h 2023-04-11 08:52:10 -07:00
credential-cache.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
credential-store.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
credential.c builtins: mark unused prefix parameters 2023-03-28 14:11:24 -07:00
describe.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
diagnose.c object-file.h: move declarations for object-file.c functions from cache.h 2023-04-11 08:52:10 -07:00
diff-files.c cocci: apply "pending" index-compatibility to some "builtin/*.c" 2022-11-21 12:06:15 +09:00
diff-index.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
diff-tree.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
diff.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
difftool.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
fast-export.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
fast-import.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
fetch-pack.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
fetch.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
fmt-merge-msg.c wrapper.h: move declarations for wrapper.c functions from cache.h 2023-03-21 10:56:53 -07:00
for-each-ref.c Merge branch 'ow/ref-filter-omit-empty' 2023-04-21 15:35:05 -07:00
for-each-repo.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
fsck.c fsck: verify checksums of all .bitmap files 2023-05-02 08:48:22 -07:00
fsmonitor--daemon.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
gc.c Merge branch 'tb/enable-cruft-packs-by-default' 2023-04-28 16:03:03 -07:00
get-tar-commit-id.c Merge branch 'rs/get-tar-commit-id-use-defined-const' 2023-04-20 14:33:36 -07:00
grep.c pager.h: move declarations for pager.c functions from cache.h 2023-04-11 08:52:10 -07:00
hash-object.c object-file.h: move declarations for object-file.c functions from cache.h 2023-04-11 08:52:10 -07:00
help.c pager.h: move declarations for pager.c functions from cache.h 2023-04-11 08:52:10 -07:00
hook.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
index-pack.c Merge branch 'tb/pack-revindex-on-disk' 2023-04-27 16:00:59 -07:00
init-db.c object-file.h: move declarations for object-file.c functions from cache.h 2023-04-11 08:52:10 -07:00
interpret-trailers.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
log.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
ls-files.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
ls-remote.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
ls-tree.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
mailinfo.c environment.h: move declarations for environment.c functions from cache.h 2023-03-21 10:56:53 -07:00
mailsplit.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
merge-base.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
merge-file.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
merge-index.c builtins: mark unused prefix parameters 2023-03-28 14:11:24 -07:00
merge-ours.c builtins: mark unused prefix parameters 2023-03-28 14:11:24 -07:00
merge-recursive.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
merge-tree.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
merge.c editor: move editor-related functions and declarations into common file 2023-04-11 08:52:10 -07:00
mktag.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
mktree.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
multi-pack-index.c environment.h: move declarations for environment.c functions from cache.h 2023-03-21 10:56:53 -07:00
mv.c object-file.h: move declarations for object-file.c functions from cache.h 2023-04-11 08:52:10 -07:00
name-rev.c pager.h: move declarations for pager.c functions from cache.h 2023-04-11 08:52:10 -07:00
notes.c editor: move editor-related functions and declarations into common file 2023-04-11 08:52:10 -07:00
pack-objects.c Merge branch 'tb/pack-revindex-on-disk' 2023-04-27 16:00:59 -07:00
pack-redundant.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
pack-refs.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
patch-id.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
prune-packed.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
prune.c object-file.h: move declarations for object-file.c functions from cache.h 2023-04-11 08:52:10 -07:00
pull.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
push.c treewide: be explicit about dependence on advice.h 2023-04-11 08:52:09 -07:00
range-diff.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
read-tree.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
rebase.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
receive-pack.c Merge branch 'jk/protocol-cap-parse-fix' 2023-04-25 13:56:20 -07:00
reflog.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
remote-ext.c builtins: annotate always-empty prefix parameters 2023-03-28 14:11:24 -07:00
remote-fd.c builtins: annotate always-empty prefix parameters 2023-03-28 14:11:24 -07:00
remote.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
repack.c Merge branch 'tb/enable-cruft-packs-by-default' 2023-04-28 16:03:03 -07:00
replace.c editor: move editor-related functions and declarations into common file 2023-04-11 08:52:10 -07:00
rerere.c wrapper.h: move declarations for wrapper.c functions from cache.h 2023-03-21 10:56:53 -07:00
reset.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
rev-list.c object-file.h: move declarations for object-file.c functions from cache.h 2023-04-11 08:52:10 -07:00
rev-parse.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
revert.c Merge branch 'pw/rebase-cleanup-merge-strategy-option-handling' 2023-04-17 18:05:13 -07:00
rm.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
send-pack.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
shortlog.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
show-branch.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
show-index.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
show-ref.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
sparse-checkout.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
stash.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
stripspace.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
submodule--helper.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
symbolic-ref.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
tag.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
unpack-file.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
unpack-objects.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
update-index.c object-file.h: move declarations for object-file.c functions from cache.h 2023-04-11 08:52:10 -07:00
update-ref.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
update-server-info.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
upload-archive.c builtins: annotate always-empty prefix parameters 2023-03-28 14:11:24 -07:00
upload-pack.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
var.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
verify-commit.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
verify-pack.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
verify-tag.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
worktree.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
write-tree.c Merge branch 'sl/sparse-write-tree' 2023-04-17 18:05:11 -07:00