git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] tests: disable fsync everywhere

From
EWEric Wong <e@80x24.org>
Date
Oct 29, 2021, 07:56 UTC
Message-ID
<20211029075640.M183252@dcvr>
In-Reply-To
<xmqqr1c4mmsf.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> 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.

Show 9 quoted lines
> > +            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).

Show 13 quoted lines
> > +            $_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.

Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 17 in “allow disabling fsync everywhere”
  1. allow disabling fsync everywhereEric Wong, Oct 28, 2021
  2. Eric SunshineOct 28, 2021
  3. Jeff KingOct 28, 2021
  4. Eric WongOct 28, 2021
  5. Junio C HamanoOct 28, 2021
  6. tests: disable fsync everywhereEric Wong, Oct 29, 2021
  7. Junio C HamanoOct 29, 2021
  8. Eric WongOct 29, 2021
  9. Junio C HamanoOct 29, 2021
  10. Junio C HamanoOct 29, 2021
  11. Eric WongOct 29, 2021
  12. Junio C HamanoOct 29, 2021
  13. Jeff KingOct 29, 2021
  14. Junio C HamanoOct 29, 2021
  15. brian m. carlsonOct 28, 2021
  16. Ævar Arnfjörð BjarmasonOct 29, 2021
  17. Eric WongOct 30, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.