Eric Wong <e@xxxxxxxxx> writes: > @@ -42,6 +42,7 @@ const char *git_hooks_path; > int zlib_compression_level = Z_BEST_SPEED; > int pack_compression_level = Z_DEFAULT_COMPRESSION; > int fsync_object_files; > +int use_fsync = -1; OK, (-1) is "undetermined yet", as usual. > diff --git a/git-cvsserver.perl b/git-cvsserver.perl > index 64319bed43..4c8118010a 100755 > --- a/git-cvsserver.perl > +++ b/git-cvsserver.perl > @@ -3607,6 +3607,22 @@ package GITCVS::updater; > use strict; > use warnings; > use DBI; > +our $_use_fsync; > + > +# n.b. consider using Git.pm > +sub use_fsync { > + if (!defined($_use_fsync)) { > + my $x = $ENV{GIT_TEST_FSYNC}; > + if (defined $x) { I would have expected to see "exists $ENV{GIT_TEST_FSYNC}", but I guess there is no way to place in %ENV anyway, so it would be OK. > + local $ENV{GIT_CONFIG}; > + delete $ENV{GIT_CONFIG}; OK, "git -c test.fsync=no cvsserver" would added something to GIT_CONFIG that would affect test.fsync, but wouldn't the usual last-one-wins rule be sufficient to check the value of $x using the next construction, no matter what is in GIT_CONFIG? I do not think it would hurt to delete $ENV{GIT_CONFIG}, but I am not sure how it is necessary. > + my $v = ::safe_pipe_capture('git', '-c', "test.fsync=$x", > + qw(config --type=bool test.fsync)); THis is an interesting idiom. > + $_use_fsync = defined($v) ? ($v eq "true\n") : 1; > + } > + } > + $_use_fsync; > +} > +# TODO: move this to Git.pm? > +sub use_fsync { Possibly, but in a slightly more general form, taking the name of the environment variable that holds a boolean value as an argument, or something? > diff --git a/t/test-lib.sh b/t/test-lib.sh > index a291a5d4a2..21f5fab999 100644 > --- a/t/test-lib.sh > +++ b/t/test-lib.sh > @@ -489,6 +489,13 @@ then > export GIT_PERL_FATAL_WARNINGS > fi > > +case $GIT_TEST_FSYNC in > +'') > + GIT_TEST_FSYNC=0 > + export GIT_TEST_FSYNC > + ;; > +esac > diff --git a/write-or-die.c b/write-or-die.c > index 0b1ec8190b..a3d5784cec 100644 > --- a/write-or-die.c > +++ b/write-or-die.c > @@ -1,4 +1,5 @@ > #include "cache.h" > +#include "config.h" > #include "run-command.h" > > /* > @@ -57,6 +58,10 @@ void fprintf_or_die(FILE *f, const char *fmt, ...) > > void fsync_or_die(int fd, const char *msg) > { > + if (use_fsync < 0) > + use_fsync = git_env_bool("GIT_TEST_FSYNC", 1); > + if (!use_fsync) > + return; OK. That's quite straight-forward. > while (fsync(fd) < 0) { > if (errno != EINTR) > die_errno("fsync error on '%s'", msg); Will queue.