From f2af9f5e02380ba3868df7daa34368945d500206 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 2 Apr 2018 16:34:14 -0400 Subject: csum-file: rename hashclose() to finalize_hashfile() The hashclose() method behaves very differently depending on the flags parameter. In particular, the file descriptor is not always closed. Perform a simple rename of "hashclose()" to "finalize_hashfile()" in preparation for functional changes. Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- bulk-checkin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bulk-checkin.c') diff --git a/bulk-checkin.c b/bulk-checkin.c index 8bcd1c8665..e8094f5f61 100644 --- a/bulk-checkin.c +++ b/bulk-checkin.c @@ -35,9 +35,9 @@ static void finish_bulk_checkin(struct bulk_checkin_state *state) unlink(state->pack_tmp_name); goto clear_exit; } else if (state->nr_written == 1) { - hashclose(state->f, oid.hash, CSUM_FSYNC); + finalize_hashfile(state->f, oid.hash, CSUM_FSYNC); } else { - int fd = hashclose(state->f, oid.hash, 0); + int fd = finalize_hashfile(state->f, oid.hash, 0); fixup_pack_header_footer(fd, oid.hash, state->pack_tmp_name, state->nr_written, oid.hash, state->offset); -- cgit v1.2.3 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 --- bulk-checkin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bulk-checkin.c') diff --git a/bulk-checkin.c b/bulk-checkin.c index e8094f5f61..a3e1b59d0e 100644 --- a/bulk-checkin.c +++ b/bulk-checkin.c @@ -35,7 +35,7 @@ static void finish_bulk_checkin(struct bulk_checkin_state *state) unlink(state->pack_tmp_name); goto clear_exit; } else if (state->nr_written == 1) { - finalize_hashfile(state->f, oid.hash, CSUM_FSYNC); + finalize_hashfile(state->f, oid.hash, CSUM_HASH_IN_STREAM | CSUM_FSYNC | CSUM_CLOSE); } else { int fd = finalize_hashfile(state->f, oid.hash, 0); fixup_pack_header_footer(fd, oid.hash, state->pack_tmp_name, -- cgit v1.2.3