git-commit-vandalism/builtin
Derrick Stolee 5a6072f631 fsck: validate .rev file header
While parsing a .rev file, we check the header information to be sure it
makes sense. This happens before doing any additional validation such as
a checksum or value check. In order to differentiate between a bad
header and a non-existent file, we need to update the API for loading a
reverse index.

Make load_pack_revindex_from_disk() non-static and specify that a
positive value means "the file does not exist" while other errors during
parsing are negative values. Since an invalid header prevents setting up
the structures we would use for further validations, we can stop at that
point.

The place where we can distinguish between a missing file and a corrupt
file is inside load_revindex_from_disk(), which is used both by pack
rev-indexes and multi-pack-index rev-indexes. Some tests in t5326
demonstrate that it is critical to take some conditions to allow
positive error signals.

Add tests that check the three header values.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2023-04-17 14:39:05 -07:00
..
add.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
am.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
annotate.c
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 Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
blame.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
branch.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
bugreport.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -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 Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
check-attr.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-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 Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -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 'jc/clone-object-format-from-void' 2023-04-11 13:49:13 -07:00
column.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
commit-graph.c environment.h: move declarations for environment.c functions from cache.h 2023-03-21 10:56:53 -07:00
commit-tree.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
commit.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
config.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -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 abspath.h: move absolute path functions from cache.h 2023-03-21 10:56:52 -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-cleanup' 2023-04-06 13:38:31 -07:00
diagnose.c abspath.h: move absolute path functions from cache.h 2023-03-21 10:56:52 -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-cleanup' 2023-04-06 13:38:31 -07:00
fast-export.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
fast-import.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
fetch-pack.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
fetch.c Merge branch 'ds/fetch-bundle-uri-with-all' 2023-04-06 13:38:32 -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 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
for-each-repo.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
fsck.c fsck: validate .rev file header 2023-04-17 14:39:05 -07:00
fsmonitor--daemon.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
gc.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
get-tar-commit-id.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
grep.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
hash-object.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
help.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
hook.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
index-pack.c t: invert GIT_TEST_WRITE_REV_INDEX 2023-04-13 07:55:46 -07:00
init-db.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -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-cleanup' 2023-04-06 13:38:31 -07:00
ls-files.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
ls-remote.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
ls-tree.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -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 Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -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-cleanup' 2023-04-06 13:38:31 -07:00
merge-tree.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
merge.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
mktag.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -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 setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
name-rev.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
notes.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
pack-objects.c t: invert GIT_TEST_WRITE_REV_INDEX 2023-04-13 07:55:46 -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 Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
pull.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
push.c environment.h: move declarations for environment.c functions from cache.h 2023-03-21 10:56:53 -07:00
range-diff.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
read-tree.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
rebase.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
receive-pack.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -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 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
replace.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -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 Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
rev-list.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
rev-parse.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
revert.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
rm.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -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 Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
show-index.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
show-ref.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
sparse-checkout.c Merge branch 'ws/sparse-check-rules' 2023-04-11 13:49:12 -07:00
stash.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -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-cleanup' 2023-04-06 13:38:31 -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-cleanup' 2023-04-06 13:38:31 -07:00
unpack-file.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
unpack-objects.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
update-index.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
update-ref.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -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 builtins: mark unused prefix parameters 2023-03-28 14:11:24 -07:00
verify-commit.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
verify-pack.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
verify-tag.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
worktree.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
write-tree.c environment.h: move declarations for environment.c functions from cache.h 2023-03-21 10:56:53 -07:00