File tree Expand file tree Collapse file tree 5 files changed +16
-1
lines changed
Expand file tree Collapse file tree 5 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,7 @@ typedef enum {
179179 GIT_OPT_SET_SSL_CIPHERS ,
180180 GIT_OPT_GET_USER_AGENT ,
181181 GIT_OPT_ENABLE_OFS_DELTA ,
182+ GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION ,
182183} git_libgit2_opt_t ;
183184
184185/**
@@ -316,6 +317,13 @@ typedef enum {
316317 * > Packfiles containing offset deltas can still be read.
317318 * > This defaults to enabled.
318319 *
320+ * * opts(GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION, int enabled)
321+ *
322+ * > Enable synchronized writes of new objects using `fsync`
323+ * > (or the platform equivalent) to ensure that new object data
324+ * > is written to permanent storage, not simply cached. This
325+ * > defaults to disabled.
326+ *
319327 * @param option Option key
320328 * @param ... value to set the option
321329 * @return 0 on success, <0 on failure
Original file line number Diff line number Diff line change 1616#include "tag.h"
1717
1818bool git_object__strict_input_validation = true;
19+ bool git_object__synchronized_writing = false;
1920
2021typedef struct {
2122 const char * str ; /* type name string */
Original file line number Diff line number Diff line change 1010#include "repository.h"
1111
1212extern bool git_object__strict_input_validation ;
13+ extern bool git_object__synchronized_writing ;
1314
1415/** Base git object for inheritance */
1516struct git_object {
Original file line number Diff line number Diff line change 1414#include "odb.h"
1515#include "delta.h"
1616#include "filebuf.h"
17+ #include "object.h"
1718
1819#include "git2/odb_backend.h"
1920#include "git2/types.h"
@@ -843,7 +844,7 @@ static int filebuf_flags(loose_backend *backend)
843844 int flags = GIT_FILEBUF_TEMPORARY |
844845 (backend -> object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT );
845846
846- if (backend -> fsync_object_files )
847+ if (backend -> fsync_object_files || git_object__synchronized_writing )
847848 flags |= GIT_FILEBUF_FSYNC ;
848849
849850 return flags ;
Original file line number Diff line number Diff line change @@ -227,6 +227,10 @@ int git_libgit2_opts(int key, ...)
227227 git_smart__ofs_delta_enabled = (va_arg (ap , int ) != 0 );
228228 break ;
229229
230+ case GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION :
231+ git_object__synchronized_writing = (va_arg (ap , int ) != 0 );
232+ break ;
233+
230234 default :
231235 giterr_set (GITERR_INVALID , "invalid option key" );
232236 error = -1 ;
You can’t perform that action at this time.
0 commit comments