git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>,
	git@vger.kernel.org, Eric Sunshine <sunshine@sunshineco.com>,
	"brian m. carlson" <sandals@crustytoothpaste.net>
Subject: Re: [PATCH] tests: disable fsync everywhere
Date: Fri, 29 Oct 2021 07:56:40 +0000	[thread overview]
Message-ID: <20211029075640.M183252@dcvr> (raw)
In-Reply-To: <xmqqr1c4mmsf.fsf@gitster.g>

Junio C Hamano <gitster@pobox.com> wrote:
> Eric Wong <e@80x24.org> writes:
> > +# 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.

Was that meant to say: "no way to place `undef' in %ENV anyway"?

If so, `undef' can actually be in Perl's %ENV, though it appears
to get coerced into "" (empty string) when spawning processes.

> > +            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.

Leaving GIT_CONFIG set was actually causing "git config" to
exit(1) since git-cvsserver sets GIT_CONFIG and the GIT_CONFIG
file doesn't have a test.fsync setting.  This is the current
behavior, I think it's a weird quirk, but intended behavior of
git-config.

# this assumes you don't have foo.bar set in your ~/.gitconfig :>
$ GIT_CONFIG=$HOME/.gitconfig git -c foo.bar=0 config --type=bool foo.bar
$ echo $?
1

> > +            my $v = ::safe_pipe_capture('git', '-c', "test.fsync=$x",
> > +                                        qw(config --type=bool test.fsync));
> 
> THis is an interesting idiom.

Heh, I just thought of it before sending my original.  I was
going to use a regexp originally (in git-svn, too), but didn't
want to get into corner cases such as hex and +/- prefixes).

> > +            $_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?

Yeah.  It would've been more useful if git-cvsserver used Git.pm;
but I didn't want to introduce Git.pm into git-cvsserver in case
somebody relies on git-cvsserver being standalone.

  reply	other threads:[~2021-10-29  7:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28  0:21 [PATCH] allow disabling fsync everywhere Eric Wong
2021-10-28  1:21 ` Eric Sunshine
2021-10-28 14:36 ` Jeff King
2021-10-28 18:28   ` Eric Wong
2021-10-28 19:29     ` Junio C Hamano
2021-10-29  0:15       ` [PATCH] tests: disable " Eric Wong
2021-10-29  5:18         ` Junio C Hamano
2021-10-29  7:56           ` Eric Wong [this message]
2021-10-29 18:12             ` Junio C Hamano
2021-10-29  7:33         ` Junio C Hamano
2021-10-29  7:48           ` Eric Wong
2021-10-29 17:22             ` Junio C Hamano
2021-10-29 20:34         ` Jeff King
2021-10-29 20:42           ` Junio C Hamano
2021-10-28 21:40     ` [PATCH] allow disabling " brian m. carlson
2021-10-29 11:20 ` Ævar Arnfjörð Bjarmason
2021-10-30 10:39   ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211029075640.M183252@dcvr \
    --to=e@80x24.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=sandals@crustytoothpaste.net \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).