diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2018-04-02 16:34:15 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-04-02 14:27:30 -0700 |
commit | cfe83216e404223ce8c5f6ef79c4ba9a27ff872e (patch) | |
tree | 6f64a9ccff4777e87bd43fdf8e051a215048ae63 /builtin/pack-objects.c | |
parent | csum-file: rename hashclose() to finalize_hashfile() (diff) | |
download | tgif-cfe83216e404223ce8c5f6ef79c4ba9a27ff872e.tar.xz |
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 <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/pack-objects.c')
-rw-r--r-- | builtin/pack-objects.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 5126623e03..c4a5a9572a 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -837,9 +837,9 @@ static void write_pack_file(void) * If so, rewrite it like in fast-import */ if (pack_to_stdout) { - finalize_hashfile(f, oid.hash, CSUM_CLOSE); + finalize_hashfile(f, oid.hash, CSUM_HASH_IN_STREAM | CSUM_CLOSE); } else if (nr_written == nr_remaining) { - finalize_hashfile(f, oid.hash, CSUM_FSYNC); + finalize_hashfile(f, oid.hash, CSUM_HASH_IN_STREAM | CSUM_FSYNC | CSUM_CLOSE); } else { int fd = finalize_hashfile(f, oid.hash, 0); fixup_pack_header_footer(fd, oid.hash, pack_tmp_name, |