Skip to content

Commit 8a94d83

Browse files
neerajsi-msftgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 425d290 commit 8a94d83

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

cache.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,10 @@ enum fsync_component {
10281028
FSYNC_COMPONENT_COMMIT_GRAPH | \
10291029
FSYNC_COMPONENT_INDEX)
10301030

1031+
#ifndef FSYNC_COMPONENTS_PLATFORM_DEFAULT
1032+
#define FSYNC_COMPONENTS_PLATFORM_DEFAULT FSYNC_COMPONENTS_DEFAULT
1033+
#endif
1034+
10311035
/*
10321036
* A bitmask indicating which components of the repo should be fsynced.
10331037
*/

compat/mingw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ int mingw_getpagesize(void);
332332
int win32_fsync_no_flush(int fd);
333333
#define fsync_no_flush win32_fsync_no_flush
334334

335+
#define FSYNC_COMPONENTS_PLATFORM_DEFAULT (FSYNC_COMPONENTS_DEFAULT | FSYNC_COMPONENT_LOOSE_OBJECT)
336+
#define FSYNC_METHOD_DEFAULT (FSYNC_METHOD_BATCH)
337+
335338
struct rlimit {
336339
unsigned int rlim_cur;
337340
};

config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ static const struct fsync_component_name {
13411341

13421342
static enum fsync_component parse_fsync_components(const char *var, const char *string)
13431343
{
1344-
enum fsync_component current = FSYNC_COMPONENTS_DEFAULT;
1344+
enum fsync_component current = FSYNC_COMPONENTS_PLATFORM_DEFAULT;
13451345
enum fsync_component positive = 0, negative = 0;
13461346

13471347
while (string) {

git-compat-util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,11 +1257,13 @@ __attribute__((format (printf, 3, 4))) NORETURN
12571257
void BUG_fl(const char *file, int line, const char *fmt, ...);
12581258
#define BUG(...) BUG_fl(__FILE__, __LINE__, __VA_ARGS__)
12591259

1260+
#ifndef FSYNC_METHOD_DEFAULT
12601261
#ifdef __APPLE__
12611262
#define FSYNC_METHOD_DEFAULT FSYNC_METHOD_WRITEOUT_ONLY
12621263
#else
12631264
#define FSYNC_METHOD_DEFAULT FSYNC_METHOD_FSYNC
12641265
#endif
1266+
#endif
12651267

12661268
enum fsync_action {
12671269
FSYNC_WRITEOUT_ONLY,

0 commit comments

Comments
 (0)