core.fsync: use batch mode and sync loose objects by default on Windows

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>

Neeraj Singh committed Apr 4, 2022 at 22:20 UTC 8a94d833497f3b8232684271c80a7da56f930939
4 files changed +10 -1
cache.h
+4
@@ -1028,6 +1028,10 @@ enum fsync_component {
1028 FSYNC_COMPONENT_COMMIT_GRAPH | \
1029 FSYNC_COMPONENT_INDEX)
1030
1031 +#ifndef FSYNC_COMPONENTS_PLATFORM_DEFAULT
1032 +#define FSYNC_COMPONENTS_PLATFORM_DEFAULT FSYNC_COMPONENTS_DEFAULT
1033 +#endif
1034 +
1035 /*
1036 * A bitmask indicating which components of the repo should be fsynced.
1037 */
compat/mingw.h
+3
@@ -332,6 +332,9 @@ int mingw_getpagesize(void);
332 int win32_fsync_no_flush(int fd);
333 #define fsync_no_flush win32_fsync_no_flush
334
335 +#define FSYNC_COMPONENTS_PLATFORM_DEFAULT (FSYNC_COMPONENTS_DEFAULT | FSYNC_COMPONENT_LOOSE_OBJECT)
336 +#define FSYNC_METHOD_DEFAULT (FSYNC_METHOD_BATCH)
337 +
338 struct rlimit {
339 unsigned int rlim_cur;
340 };
config.c
+1 -1
@@ -1341,7 +1341,7 @@ static const struct fsync_component_name {
1341
1342 static enum fsync_component parse_fsync_components(const char *var, const char *string)
1343 {
1344 - enum fsync_component current = FSYNC_COMPONENTS_DEFAULT;
1344 + enum fsync_component current = FSYNC_COMPONENTS_PLATFORM_DEFAULT;
1345 enum fsync_component positive = 0, negative = 0;
1346
1347 while (string) {
git-compat-util.h
+2
@@ -1257,11 +1257,13 @@ __attribute__((format (printf, 3, 4))) NORETURN
1257 void BUG_fl(const char *file, int line, const char *fmt, ...);
1258 #define BUG(...) BUG_fl(__FILE__, __LINE__, __VA_ARGS__)
1259
1260 +#ifndef FSYNC_METHOD_DEFAULT
1261 #ifdef __APPLE__
1262 #define FSYNC_METHOD_DEFAULT FSYNC_METHOD_WRITEOUT_ONLY
1263 #else
1264 #define FSYNC_METHOD_DEFAULT FSYNC_METHOD_FSYNC
1265 #endif
1266 +#endif
1267
1268 enum fsync_action {
1269 FSYNC_WRITEOUT_ONLY,