]> git.ipfire.org Git - thirdparty/git.git/commitdiff
core.fsync: use batch mode and sync loose objects by default on Windows
authorNeeraj Singh <neerajsi@microsoft.com>
Tue, 5 Apr 2022 05:20:14 +0000 (22:20 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Apr 2022 20:13:26 +0000 (13:13 -0700)
Git for Windows has defaulted to core.fsyncObjectFiles=true since
September 2017. We turn on syncing of loose object files with batch mode
in upstream Git so that we can get broad coverage of the new code
upstream.

We don't actually do fsyncs in the most of the test suite, since
GIT_TEST_FSYNC is set to 0. However, we do exercise all of the
surrounding batch mode code since GIT_TEST_FSYNC merely makes the
maybe_fsync wrapper always appear to succeed.

Signed-off-by: Neeraj Singh <neerajsi@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
compat/mingw.h
config.c
git-compat-util.h

diff --git a/cache.h b/cache.h
index ca0085717dfbdc804130f7ed2b11d50f6d41b3a0..2b5f61418480ace855d9cf9a7e7fe52b55cd91f5 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1028,6 +1028,10 @@ enum fsync_component {
                              FSYNC_COMPONENT_COMMIT_GRAPH | \
                              FSYNC_COMPONENT_INDEX)
 
+#ifndef FSYNC_COMPONENTS_PLATFORM_DEFAULT
+#define FSYNC_COMPONENTS_PLATFORM_DEFAULT FSYNC_COMPONENTS_DEFAULT
+#endif
+
 /*
  * A bitmask indicating which components of the repo should be fsynced.
  */
index 6074a3d3cedb56b19a1d4d4cce98a82ff06e14f3..afe30868c043d3b096e1f65c7980a291cdfff1b5 100644 (file)
@@ -332,6 +332,9 @@ int mingw_getpagesize(void);
 int win32_fsync_no_flush(int fd);
 #define fsync_no_flush win32_fsync_no_flush
 
+#define FSYNC_COMPONENTS_PLATFORM_DEFAULT (FSYNC_COMPONENTS_DEFAULT | FSYNC_COMPONENT_LOOSE_OBJECT)
+#define FSYNC_METHOD_DEFAULT (FSYNC_METHOD_BATCH)
+
 struct rlimit {
        unsigned int rlim_cur;
 };
index 6d4caac476ef7c4e92cf974cef4933c71fc082c9..8e31b49ea919ccd46bed4530304b173ce88158df 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1341,7 +1341,7 @@ static const struct fsync_component_name {
 
 static enum fsync_component parse_fsync_components(const char *var, const char *string)
 {
-       enum fsync_component current = FSYNC_COMPONENTS_DEFAULT;
+       enum fsync_component current = FSYNC_COMPONENTS_PLATFORM_DEFAULT;
        enum fsync_component positive = 0, negative = 0;
 
        while (string) {
index 0892e209a2fb23f797030dd04c62cd534e3d1775..fffe42ce7c16825fb679bc9ebfbe847bfccd9fd9 100644 (file)
@@ -1257,11 +1257,13 @@ __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__)
 
+#ifndef FSYNC_METHOD_DEFAULT
 #ifdef __APPLE__
 #define FSYNC_METHOD_DEFAULT FSYNC_METHOD_WRITEOUT_ONLY
 #else
 #define FSYNC_METHOD_DEFAULT FSYNC_METHOD_FSYNC
 #endif
+#endif
 
 enum fsync_action {
        FSYNC_WRITEOUT_ONLY,