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 --- pack-write.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pack-write.c') diff --git a/pack-write.c b/pack-write.c index 044f427392..a9d46bc03f 100644 --- a/pack-write.c +++ b/pack-write.c @@ -170,8 +170,9 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec } hashwrite(f, sha1, the_hash_algo->rawsz); - finalize_hashfile(f, NULL, ((opts->flags & WRITE_IDX_VERIFY) - ? CSUM_CLOSE : CSUM_FSYNC)); + finalize_hashfile(f, NULL, CSUM_HASH_IN_STREAM | CSUM_CLOSE | + ((opts->flags & WRITE_IDX_VERIFY) + ? 0 : CSUM_FSYNC)); return index_name; } -- cgit v1.2.3