From cfe83216e404223ce8c5f6ef79c4ba9a27ff872e Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 2 Apr 2018 16:34:15 -0400 Subject: csum-file: refactor finalize_hashfile() method If we want to use a hashfile on the temporary file for a lockfile, then we need finalize_hashfile() to fully write the trailing hash but also keep the file descriptor open. Do this by adding a new CSUM_HASH_IN_STREAM flag along with a functional change that checks this flag before writing the checksum to the stream. This differs from previous behavior since it would be written if either CSUM_CLOSE or CSUM_FSYNC is provided. Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- csum-file.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'csum-file.h') diff --git a/csum-file.h b/csum-file.h index 9ba87f0a6c..c5a2e335e7 100644 --- a/csum-file.h +++ b/csum-file.h @@ -27,8 +27,9 @@ extern void hashfile_checkpoint(struct hashfile *, struct hashfile_checkpoint *) extern int hashfile_truncate(struct hashfile *, struct hashfile_checkpoint *); /* finalize_hashfile flags */ -#define CSUM_CLOSE 1 -#define CSUM_FSYNC 2 +#define CSUM_CLOSE 1 +#define CSUM_FSYNC 2 +#define CSUM_HASH_IN_STREAM 4 extern struct hashfile *hashfd(int fd, const char *name); extern struct hashfile *hashfd_check(const char *name); -- cgit v1.2.1