aboutsummaryrefslogtreecommitdiffstats
path: root/csum-file.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-03-10 08:13:20 +0100
committerJunio C Hamano <gitster@pobox.com>2025-03-10 13:16:18 -0700
commit228457c9d9f32f000f5c04c36fcce9002f72965a (patch)
tree93bba303fb1b835729222a1978e493d0e9e5a843 /csum-file.h
parentA few more after -rc1 (diff)
downloadgit-228457c9d9f32f000f5c04c36fcce9002f72965a.tar.gz
git-228457c9d9f32f000f5c04c36fcce9002f72965a.zip
csum-file: stop depending on `the_repository`
There are multiple sites in "csum-file.c" where we use the global `the_repository` variable, either explicitly or implicitly by using `the_hash_algo`. Refactor the code to stop using `the_repository` by adapting functions to receive required data as parameters. Adapt callsites accordingly by either using `the_repository->hash_algo`, or by using a context-provided hash algorithm in case the subsystem already got rid of its dependency on `the_repository`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'csum-file.h')
-rw-r--r--csum-file.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/csum-file.h b/csum-file.h
index ffccbf0996..07ae11024a 100644
--- a/csum-file.h
+++ b/csum-file.h
@@ -45,9 +45,12 @@ int hashfile_truncate(struct hashfile *, struct hashfile_checkpoint *);
#define CSUM_FSYNC 2
#define CSUM_HASH_IN_STREAM 4
-struct hashfile *hashfd(int fd, const char *name);
-struct hashfile *hashfd_check(const char *name);
-struct hashfile *hashfd_throughput(int fd, const char *name, struct progress *tp);
+struct hashfile *hashfd(const struct git_hash_algo *algop,
+ int fd, const char *name);
+struct hashfile *hashfd_check(const struct git_hash_algo *algop,
+ const char *name);
+struct hashfile *hashfd_throughput(const struct git_hash_algo *algop,
+ int fd, const char *name, struct progress *tp);
/*
* Free the hashfile without flushing its contents to disk. This only
@@ -66,7 +69,8 @@ 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);
+int hashfile_checksum_valid(const struct git_hash_algo *algop,
+ const unsigned char *data, size_t len);
/*
* Returns the total number of bytes fed to the hashfile so far (including ones