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

Re: [PATCH v4] branch: introduce --show-current display option

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 17, 2018, 10:18 UTC
Message-ID
<nycvar.QRO.7.76.6.1810171211440.4546@tvgsbejvaqbjf.bet>
In-Reply-To
<CAPig+cRwy2Xhq7uJJ0OfY2nRZgPK9yHr=G+KMKuWx-PXyWv8Gg@mail.gmail.com>
Hi Eric,
On Tue, 16 Oct 2018, Eric Sunshine wrote:
Show 41 quoted lines
> On Tue, Oct 16, 2018 at 7:09 PM Junio C Hamano <gitster@pobox.com> wrote:
> > Eric Sunshine <sunshine@sunshineco.com> writes:
> > > This cleanup "checkout" needs to be encapsulated within a
> > > test_when_finished(), doesn't it? Preferably just after the "git
> > > checkout -b" invocation.
> >
> > In the meantime, here is what I'll have in 'pu' on top.
> >
> > diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh
> > @@ -119,12 +119,14 @@ test_expect_success 'git branch `--show-current` works properly when tag exists'
> >         cat >expect <<-\EOF &&
> >         branch-and-tag-name
> >         EOF
> > -       test_when_finished "git branch -D branch-and-tag-name" &&
> > +       test_when_finished "
> > +               git checkout branch-one
> > +               git branch -D branch-and-tag-name
> > +       " &&
> >         git checkout -b branch-and-tag-name &&
> >         test_when_finished "git tag -d branch-and-tag-name" &&
> >         git tag branch-and-tag-name &&
> >         git branch --show-current >actual &&
> > -       git checkout branch-one &&
> >         test_cmp expect actual
> >  '
> 
> This make sense to me.
> 
> > @@ -137,8 +139,7 @@ test_expect_success 'git branch `--show-current` works properly with worktrees'
> >         git worktree add worktree branch-two &&
> >         (
> >                 git branch --show-current &&
> > -               cd worktree &&
> > -               git branch --show-current
> > +               git -C worktree branch --show-current
> >         ) >actual &&
> >         test_cmp expect actual
> >  '
> 
> The subshell '(...)' could become '{...}' now that the 'cd' is gone,
> but that's a minor point.
Maybe not so minor.

I realized yesterday that the &&-chain linting we use for every single test case takes a noticeable chunk of time:

	$ time ./t0006-date.sh --quiet
	# passed all 67 test(s)
	1..67
	real    0m20.973s
	user    0m2.662s
	sys     0m14.789s
	$ time ./t0006-date.sh --quiet --no-chain-lint
	# passed all 67 test(s)
	1..67
	real    0m13.607s
	user    0m1.330s
	sys     0m8.070s

My suspicion: it is essentially the `(exit 117)` that adds about 100ms to every of those 67 test cases.

(Remember: a subshell requires a fork, and the `fork()` emulation on Windows requires all kinds of things to be copied to a new process, including memory and open file descriptors, before the `exec()` will undo at least part of that.)

With that in mind, I would like to suggest that we should start to be very careful about using subshells in our test suite.

Ciao, Dscho

Previous: Eric SunshineNext: Eric Sunshine
Message 21 of 30 in “branch: introduce --show-current display option”
  1. 0/1 branch: introduce --show-current display optionDaniels Umanovskis, Oct 10, 2018
  2. 1/1 branch: introduce --show-current display optionDaniels Umanovskis, Oct 10, 2018
  3. Jeff KingOct 11, 2018
  4. Rafael AscensãoOct 11, 2018
  5. Daniels UmanovskisOct 11, 2018
  6. Jeff KingOct 11, 2018
  7. Rafael AscensãoOct 11, 2018
  8. Daniels UmanovskisOct 11, 2018
  9. Jeff KingOct 11, 2018
  10. Rafael AscensãoOct 11, 2018
  11. Junio C HamanoOct 11, 2018
  12. Daniels UmanovskisOct 11, 2018
  13. Jeff KingOct 11, 2018
  14. branch: introduce --show-current display optionDaniels Umanovskis, Oct 11, 2018
  15. Junio C HamanoOct 11, 2018
  16. Daniels UmanovskisOct 11, 2018
  17. branch: introduce --show-current display optionDaniels Umanovskis, Oct 12, 2018
  18. Eric SunshineOct 12, 2018
  19. Junio C HamanoOct 16, 2018
  20. Eric SunshineOct 16, 2018
  21. Johannes SchindelinOct 17, 2018
  22. Eric SunshineOct 17, 2018
  23. Johannes SchindelinOct 18, 2018
  24. Eric SunshineOct 18, 2018
  25. Junio C HamanoOct 16, 2018
  26. Rafael AscensãoOct 17, 2018
  27. Daniels UmanovskisOct 17, 2018
  28. SZEDER GáborOct 11, 2018
  29. SZEDER GáborOct 11, 2018
  30. Daniels UmanovskisOct 11, 2018

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.