summaryrefslogtreecommitdiff
path: root/csum-file.h
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2021-06-23 18:39:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-06-29 03:36:17 (GMT)
commitf9221e2cf5049805d9151b3db6a5eef07b1cc92e (patch)
tree962e5c2742ae80de7f45353ba5813580caeeaa99 /csum-file.h
parentebf3c04b262aa27fbb97f8a0156c2347fecafafb (diff)
downloadgit-f9221e2cf5049805d9151b3db6a5eef07b1cc92e.zip
git-f9221e2cf5049805d9151b3db6a5eef07b1cc92e.tar.gz
git-f9221e2cf5049805d9151b3db6a5eef07b1cc92e.tar.bz2
csum-file: introduce checksum_valid()
Introduce a new function which checks the validity of a file's trailing checksum. This is similar to hashfd_check(), but different since it is intended to be used by callers who aren't writing the same data (like `git index-pack --verify`), but who instead want to validate the integrity of data that they are reading. Rewrite the first of two callers which could benefit from this new function in pack-check.c. Subsequent callers will be added in the following patches. Helped-by: Jeff King <peff@peff.net> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'csum-file.h')
-rw-r--r--csum-file.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/csum-file.h b/csum-file.h
index e54d53d..87e3879 100644
--- a/csum-file.h
+++ b/csum-file.h
@@ -42,6 +42,9 @@ void hashflush(struct hashfile *f);
void crc32_begin(struct hashfile *);
uint32_t crc32_end(struct hashfile *);
+/* Verify checksum validity while reading. Returns non-zero on success. */
+int hashfile_checksum_valid(const unsigned char *data, size_t len);
+
/*
* Returns the total number of bytes fed to the hashfile so far (including ones
* that have not been written out to the descriptor yet).