diff options
author | Derrick Stolee <derrickstolee@github.com> | 2023-04-17 19:21:41 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-04-18 00:39:05 +0300 |
commit | 5a6072f631dcf4d9f65e83b08d14c82e2af45dd8 (patch) | |
tree | 4868d4798a2d84684f77a1c09788876db317bf79 /pack-revindex.h | |
parent | 5f658d1b577722111564f51962d6af33d1fe96c6 (diff) |
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>
Diffstat (limited to 'pack-revindex.h')
-rw-r--r-- | pack-revindex.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pack-revindex.h b/pack-revindex.h index c8861873b0..6dd47efea1 100644 --- a/pack-revindex.h +++ b/pack-revindex.h @@ -52,6 +52,14 @@ struct repository; int load_pack_revindex(struct repository *r, struct packed_git *p); /* + * Specifically load a pack revindex from disk. + * + * Returns 0 on success, 1 on "no .rev file", and -1 when there is an + * error parsing the .rev file. + */ +int load_pack_revindex_from_disk(struct packed_git *p); + +/* * verify_pack_revindex verifies that the on-disk rev-index for the given * pack-file is the same that would be created if written from scratch. * |