Skip to content

Commit 61ba069

Browse files
neerajsi-msftvdye
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 6aa8789 commit 61ba069

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
@@ -1031,6 +1031,10 @@ enum fsync_component {
10311031
FSYNC_COMPONENT_INDEX | \
10321032
FSYNC_COMPONENT_REFERENCE)
10331033

1034+
#ifndef FSYNC_COMPONENTS_PLATFORM_DEFAULT
1035+
#define FSYNC_COMPONENTS_PLATFORM_DEFAULT FSYNC_COMPONENTS_DEFAULT
1036+
#endif
1037+
10341038
/*
10351039
* A bitmask indicating which components of the repo should be fsynced.
10361040
*/

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
@@ -1342,7 +1342,7 @@ static const struct fsync_component_name {
13421342

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

13481348
while (string) {

git-compat-util.h

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

1264+
#ifndef FSYNC_METHOD_DEFAULT
12641265
#ifdef __APPLE__
12651266
#define FSYNC_METHOD_DEFAULT FSYNC_METHOD_WRITEOUT_ONLY
12661267
#else
12671268
#define FSYNC_METHOD_DEFAULT FSYNC_METHOD_FSYNC
12681269
#endif
1270+
#endif
12691271

12701272
enum fsync_action {
12711273
FSYNC_WRITEOUT_ONLY,

0 commit comments

Comments
 (0)