summaryrefslogtreecommitdiff
path: root/src/indexer.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-12-14 12:51:40 -0500
committerEdward Thomson <ethomson@github.com>2017-02-28 13:27:50 +0000
commit1c2c0ae2a4d09f5b0de3c4c091c5a93ab34baa46 (patch)
tree436f1573473606ef78b9f6f24f5548fd0c055171 /src/indexer.c
parente6ed0d2f03625f5d6b60db54fc894902d7ddbc32 (diff)
downloadlibgit2-1c2c0ae2a4d09f5b0de3c4c091c5a93ab34baa46.tar.gz
packbuilder: honor git_object__synchronized_writing
Honor `git_object__synchronized_writing` when creating a packfile and corresponding index.
Diffstat (limited to 'src/indexer.c')
-rw-r--r--src/indexer.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/indexer.c b/src/indexer.c
index 869e2299f..30c365565 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -17,6 +17,7 @@
#include "oid.h"
#include "oidmap.h"
#include "zstream.h"
+#include "object.h"
extern git_mutex git__mwindow_mutex;
@@ -989,7 +990,9 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
return -1;
if (git_filebuf_open(&index_file, filename.ptr,
- GIT_FILEBUF_HASH_CONTENTS, idx->mode) < 0)
+ GIT_FILEBUF_HASH_CONTENTS |
+ (git_object__synchronized_writing ? GIT_FILEBUF_FSYNC : 0),
+ idx->mode) < 0)
goto on_error;
/* Write out the header */
@@ -1066,6 +1069,11 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
return -1;
}
+ if (git_object__synchronized_writing && p_fsync(idx->pack->mwf.fd) < 0) {
+ giterr_set(GITERR_OS, "failed to fsync packfile");
+ goto on_error;
+ }
+
/* We need to close the descriptor here so Windows doesn't choke on commit_at */
if (p_close(idx->pack->mwf.fd) < 0) {
giterr_set(GITERR_OS, "failed to close packfile");