Skip to content

Commit

Permalink
mingw: change core.fsyncObjectFiles = 1 by default
Browse files Browse the repository at this point in the history
From the documentation of said setting:

	This boolean will enable fsync() when writing object files.

	This is a total waste of time and effort on a filesystem that
	orders data writes properly, but can be useful for filesystems
	that do not use journalling (traditional UNIX filesystems) or
	that only journal metadata and not file contents (OS X’s HFS+,
	or Linux ext3 with "data=writeback").

The most common file system on Windows (NTFS) does not guarantee that
order, therefore a sudden loss of power (or any other event causing an
unclean shutdown) would cause corrupt files (i.e. files filled with
NULs). Therefore we need to change the default.

Note that the documentation makes it sound as if this causes really bad
performance. In reality, writing loose objects is something that is done
only rarely, and only a handful of files at a time.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Sep 24, 2024
1 parent 14c432a commit d6c73a5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "gettext.h"
#define SECURITY_WIN32
#include <sspi.h>
#include "../write-or-die.h"
#include "../repository.h"

#define HCAST(type, handle) ((type)(intptr_t)handle)
Expand Down Expand Up @@ -3130,6 +3131,7 @@ int wmain(int argc, const wchar_t **wargv)
#endif

maybe_redirect_std_handles();
fsync_object_files = 1;

/* determine size of argv and environ conversion buffer */
maxlen = wcslen(wargv[0]);
Expand Down

0 comments on commit d6c73a5

Please sign in to comment.