Skip to content

Commit 014403c

Browse files
neerajsi-msftdscho
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 4060b73 commit 014403c

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
@@ -1273,11 +1273,13 @@ __attribute__((format (printf, 3, 4))) NORETURN
12731273
void BUG_fl(const char *file, int line, const char *fmt, ...);
12741274
#define BUG(...) BUG_fl(__FILE__, __LINE__, __VA_ARGS__)
12751275

1276+
#ifndef FSYNC_METHOD_DEFAULT
12761277
#ifdef __APPLE__
12771278
#define FSYNC_METHOD_DEFAULT FSYNC_METHOD_WRITEOUT_ONLY
12781279
#else
12791280
#define FSYNC_METHOD_DEFAULT FSYNC_METHOD_FSYNC
12801281
#endif
1282+
#endif
12811283

12821284
enum fsync_action {
12831285
FSYNC_WRITEOUT_ONLY,

0 commit comments

Comments
 (0)