]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ns/core-fsyncmethod'
authorJunio C Hamano <gitster@pobox.com>
Fri, 25 Mar 2022 23:38:24 +0000 (16:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 25 Mar 2022 23:38:24 +0000 (16:38 -0700)
Replace core.fsyncObjectFiles with two new configuration variables,
core.fsync and core.fsyncMethod.

* ns/core-fsyncmethod:
  core.fsync: documentation and user-friendly aggregate options
  core.fsync: new option to harden the index
  core.fsync: add configuration parsing
  core.fsync: introduce granular fsync control infrastructure
  core.fsyncmethod: add writeout-only mode
  wrapper: make inclusion of Windows csprng header tightly scoped

13 files changed:
1  2 
Makefile
builtin/fast-import.c
builtin/index-pack.c
builtin/pack-objects.c
bulk-checkin.c
cache.h
commit-graph.c
config.c
config.mak.uname
environment.c
git-compat-util.h
object-file.c
read-cache.c

diff --cc Makefile
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc bulk-checkin.c
Simple merge
diff --cc cache.h
Simple merge
diff --cc commit-graph.c
Simple merge
diff --cc config.c
Simple merge
Simple merge
diff --cc environment.c
Simple merge
index e50e2fafaec9d7cf378495bbf80af95cbb3d1d54,00356476a9d1dc5ea49f1e3c8ca59015311f080a..0892e209a2fb23f797030dd04c62cd534e3d1775
@@@ -1262,7 -1265,36 +1256,31 @@@ extern int BUG_exit_code
  __attribute__((format (printf, 3, 4))) NORETURN
  void BUG_fl(const char *file, int line, const char *fmt, ...);
  #define BUG(...) BUG_fl(__FILE__, __LINE__, __VA_ARGS__)
 -#else
 -__attribute__((format (printf, 1, 2))) NORETURN
 -void BUG(const char *fmt, ...);
 -#endif
  
+ #ifdef __APPLE__
+ #define FSYNC_METHOD_DEFAULT FSYNC_METHOD_WRITEOUT_ONLY
+ #else
+ #define FSYNC_METHOD_DEFAULT FSYNC_METHOD_FSYNC
+ #endif
+ enum fsync_action {
+       FSYNC_WRITEOUT_ONLY,
+       FSYNC_HARDWARE_FLUSH
+ };
+ /*
+  * Issues an fsync against the specified file according to the specified mode.
+  *
+  * FSYNC_WRITEOUT_ONLY attempts to use interfaces available on some operating
+  * systems to flush the OS cache without issuing a flush command to the storage
+  * controller. If those interfaces are unavailable, the function fails with
+  * ENOSYS.
+  *
+  * FSYNC_HARDWARE_FLUSH does an OS writeout and hardware flush to ensure that
+  * changes are durable. It is not expected to fail.
+  */
+ int git_fsync(int fd, enum fsync_action action);
  /*
   * Preserves errno, prints a message, but gives no warning for ENOENT.
   * Returns 0 on success, which includes trying to unlink an object that does
diff --cc object-file.c
Simple merge
diff --cc read-cache.c
Simple merge