]> git.ipfire.org Git - thirdparty/git.git/commitdiff
csum-file: introduce hashfile_total()
authorJeff King <peff@peff.net>
Wed, 18 Dec 2019 11:25:42 +0000 (12:25 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Jan 2020 18:51:50 +0000 (10:51 -0800)
We will need this helper function in a following commit
to give us total number of bytes fed to the hashfile so far.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
csum-file.h

index a98b1eee53f40367ad06c7aa82da7af0ca6ed6bc..f9cbd317fbbce89547a405783fb5cc69e7815efa 100644 (file)
@@ -42,6 +42,15 @@ void hashflush(struct hashfile *f);
 void crc32_begin(struct hashfile *);
 uint32_t crc32_end(struct hashfile *);
 
+/*
+ * Returns the total number of bytes fed to the hashfile so far (including ones
+ * that have not been written out to the descriptor yet).
+ */
+static inline off_t hashfile_total(struct hashfile *f)
+{
+       return f->total + f->offset;
+}
+
 static inline void hashwrite_u8(struct hashfile *f, uint8_t data)
 {
        hashwrite(f, &data, sizeof(data));