diff options
Diffstat (limited to 'csum-file.c')
| -rw-r--r-- | csum-file.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/csum-file.c b/csum-file.c index 870748e016..2131ee6b12 100644 --- a/csum-file.c +++ b/csum-file.c @@ -7,6 +7,9 @@ * files. Useful when you write a file that you want to be * able to verify hasn't been messed with afterwards. */ + +#define USE_THE_REPOSITORY_VARIABLE + #include "git-compat-util.h" #include "progress.h" #include "csum-file.h" @@ -68,12 +71,12 @@ int finalize_hashfile(struct hashfile *f, unsigned char *result, hashflush(f); if (f->skip_hash) - hashclr(f->buffer); + hashclr(f->buffer, the_repository->hash_algo); else the_hash_algo->final_fn(f->buffer, &f->ctx); if (result) - hashcpy(result, f->buffer); + hashcpy(result, f->buffer, the_repository->hash_algo); if (flags & CSUM_HASH_IN_STREAM) flush(f, f->buffer, the_hash_algo->rawsz); if (flags & CSUM_FSYNC) @@ -99,6 +102,15 @@ int finalize_hashfile(struct hashfile *f, unsigned char *result, return fd; } +void discard_hashfile(struct hashfile *f) +{ + if (0 <= f->check_fd) + close(f->check_fd); + if (0 <= f->fd) + close(f->fd); + free_hashfile(f); +} + void hashwrite(struct hashfile *f, const void *buf, unsigned int count) { while (count) { @@ -237,5 +249,5 @@ int hashfile_checksum_valid(const unsigned char *data, size_t total_len) the_hash_algo->update_fn(&ctx, data, data_len); the_hash_algo->final_fn(got, &ctx); - return hasheq(got, data + data_len); + return hasheq(got, data + data_len, the_repository->hash_algo); } |
