* [PATCH] t5614: don't use subshells
@ 2016-06-20 17:21 Stefan Beller
2016-06-21 19:18 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Beller @ 2016-06-20 17:21 UTC (permalink / raw)
To: gitster, peff; +Cc: git, Stefan Beller
Using a subshell for just one git command is both a waste in compute
overhead (create a new process) as well as in line count.
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
Junio,
This goes on top of the patch that I just sent
"[PATCH] shallow clone to not imply shallow submodules" (which is to
be squashed into "clone: do not let --depth imply --shallow-submodules".
Unlike the prior patch we would not want this patch to fall through
to origin/maint fast, but allow cooking?
Thanks,
Stefan
t/t5614-clone-submodules.sh | 70 +++++++++++++--------------------------------
1 file changed, 20 insertions(+), 50 deletions(-)
diff --git a/t/t5614-clone-submodules.sh b/t/t5614-clone-submodules.sh
index a9aaa01..da2a67f 100755
--- a/t/t5614-clone-submodules.sh
+++ b/t/t5614-clone-submodules.sh
@@ -25,76 +25,46 @@ test_expect_success 'setup' '
test_expect_success 'nonshallow clone implies nonshallow submodule' '
test_when_finished "rm -rf super_clone" &&
git clone --recurse-submodules "file://$pwd/." super_clone &&
- (
- cd super_clone &&
- git log --oneline >lines &&
- test_line_count = 3 lines
- ) &&
- (
- cd super_clone/sub &&
- git log --oneline >lines &&
- test_line_count = 3 lines
- )
+ git -C super_clone log --oneline >lines &&
+ test_line_count = 3 lines &&
+ git -C super_clone/sub log --oneline >lines &&
+ test_line_count = 3 lines
'
test_expect_success 'shallow clone with shallow submodule' '
test_when_finished "rm -rf super_clone" &&
git clone --recurse-submodules --depth 2 --shallow-submodules "file://$pwd/." super_clone &&
- (
- cd super_clone &&
- git log --oneline >lines &&
- test_line_count = 2 lines
- ) &&
- (
- cd super_clone/sub &&
- git log --oneline >lines &&
- test_line_count = 1 lines
- )
+ git -C super_clone log --oneline >lines &&
+ test_line_count = 2 lines &&
+ git -C super_clone/sub log --oneline >lines &&
+ test_line_count = 1 lines
'
test_expect_success 'shallow clone does not imply shallow submodule' '
test_when_finished "rm -rf super_clone" &&
git clone --recurse-submodules --depth 2 "file://$pwd/." super_clone &&
- (
- cd super_clone &&
- git log --oneline >lines &&
- test_line_count = 2 lines
- ) &&
- (
- cd super_clone/sub &&
- git log --oneline >lines &&
- test_line_count = 3 lines
- )
+ git -C super_clone log --oneline >lines &&
+ test_line_count = 2 lines &&
+ git -C super_clone/sub log --oneline >lines &&
+ test_line_count = 3 lines
'
test_expect_success 'shallow clone with non shallow submodule' '
test_when_finished "rm -rf super_clone" &&
git clone --recurse-submodules --depth 2 --no-shallow-submodules "file://$pwd/." super_clone &&
- (
- cd super_clone &&
- git log --oneline >lines &&
- test_line_count = 2 lines
- ) &&
- (
- cd super_clone/sub &&
- git log --oneline >lines &&
- test_line_count = 3 lines
- )
+ git -C super_clone log --oneline >lines &&
+ test_line_count = 2 lines &&
+ git -C super_clone/sub log --oneline >lines &&
+ test_line_count = 3 lines
'
test_expect_success 'non shallow clone with shallow submodule' '
test_when_finished "rm -rf super_clone" &&
git clone --recurse-submodules --no-local --shallow-submodules "file://$pwd/." super_clone &&
- (
- cd super_clone &&
- git log --oneline >lines &&
- test_line_count = 3 lines
- ) &&
- (
- cd super_clone/sub &&
- git log --oneline >lines &&
- test_line_count = 1 lines
- )
+ git -C super_clone log --oneline >lines &&
+ test_line_count = 3 lines &&
+ git -C super_clone/sub log --oneline >lines &&
+ test_line_count = 1 lines
'
test_done
--
2.7.0.rc0.40.g5328432.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] t5614: don't use subshells
2016-06-20 17:21 [PATCH] t5614: don't use subshells Stefan Beller
@ 2016-06-21 19:18 ` Junio C Hamano
2016-06-21 19:38 ` Jeff King
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2016-06-21 19:18 UTC (permalink / raw)
To: Stefan Beller; +Cc: peff, git
Stefan Beller <sbeller@google.com> writes:
> Unlike the prior patch we would not want this patch to fall through
> to origin/maint fast, but allow cooking?
I do not see anything that makes this treated differently from the
other fix. The only difference in behaviour is that "lines" file is
now created at the root level of the trash repository's working tree
instead of tested clones', and I do not think any test depends on
the number of untracked paths in the trash working tree or tries to
make sure a file called "lines" is not in there.
> diff --git a/t/t5614-clone-submodules.sh b/t/t5614-clone-submodules.sh
> index a9aaa01..da2a67f 100755
> --- a/t/t5614-clone-submodules.sh
> +++ b/t/t5614-clone-submodules.sh
> @@ -25,76 +25,46 @@ test_expect_success 'setup' '
> test_expect_success 'nonshallow clone implies nonshallow submodule' '
> test_when_finished "rm -rf super_clone" &&
> git clone --recurse-submodules "file://$pwd/." super_clone &&
> - (
> - cd super_clone &&
> - git log --oneline >lines &&
> - test_line_count = 3 lines
> - ) &&
> - (
> - cd super_clone/sub &&
> - git log --oneline >lines &&
> - test_line_count = 3 lines
> - )
> + git -C super_clone log --oneline >lines &&
> + test_line_count = 3 lines &&
> + git -C super_clone/sub log --oneline >lines &&
> + test_line_count = 3 lines
> '
Having said that, I wonder if we want further reduction of the
repetition. Each test except "setup" in this script does an
identical thing with very small set of parameters:
- make sure super_clone will be removed when done.
- clone file://$pwd/. to super_clone but with different set of options.
- check the commits in super_clone and super_clone/sub.
So, the above would ideally become something like
do_test 3 3 --recurse-submodules
where the helper would look like
do_test () {
cnt_super=$1 cnt_sub=$2 &&
shift 2 &&
test_when_finished "rm -fr super_clone" &&
git clone "$@" "file://$pwd/." super_clone &&
git -C super_clone log --oneline >lines &&
test_line_count = $cnt_super lines &&
git -C super_clone/sub log --oneline >lines &&
test_line_count = $cnt_sub lines
}
Would it rob too much flexibility from future tests to be added to
this script if we did it that way?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] t5614: don't use subshells
2016-06-21 19:18 ` Junio C Hamano
@ 2016-06-21 19:38 ` Jeff King
2016-06-21 20:14 ` Stefan Beller
0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2016-06-21 19:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Stefan Beller, git
On Tue, Jun 21, 2016 at 12:18:29PM -0700, Junio C Hamano wrote:
> Stefan Beller <sbeller@google.com> writes:
>
> > Unlike the prior patch we would not want this patch to fall through
> > to origin/maint fast, but allow cooking?
>
> I do not see anything that makes this treated differently from the
> other fix. The only difference in behaviour is that "lines" file is
> now created at the root level of the trash repository's working tree
> instead of tested clones', and I do not think any test depends on
> the number of untracked paths in the trash working tree or tries to
> make sure a file called "lines" is not in there.
I think it is only that the other patch is actually fixing something,
whereas this is cleanup. So the cost/benefit equation is different. I
agree neither is high-risk and a test cleanup is generally OK for maint
(the other is a serious-ish regression IMHO).
> Having said that, I wonder if we want further reduction of the
> repetition. Each test except "setup" in this script does an
> identical thing with very small set of parameters:
>
> - make sure super_clone will be removed when done.
> - clone file://$pwd/. to super_clone but with different set of options.
> - check the commits in super_clone and super_clone/sub.
>
> So, the above would ideally become something like
>
> do_test 3 3 --recurse-submodules
>
> where the helper would look like
>
> do_test () {
> cnt_super=$1 cnt_sub=$2 &&
> shift 2 &&
> test_when_finished "rm -fr super_clone" &&
> git clone "$@" "file://$pwd/." super_clone &&
> git -C super_clone log --oneline >lines &&
> test_line_count = $cnt_super lines &&
> git -C super_clone/sub log --oneline >lines &&
> test_line_count = $cnt_sub lines
> }
>
> Would it rob too much flexibility from future tests to be added to
> this script if we did it that way?
I think that's an improvement, too. Even if we add further tests, they
don't have to follow the same format. I would give the function a better
name than "do_test" though. :P
-Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] t5614: don't use subshells
2016-06-21 19:38 ` Jeff King
@ 2016-06-21 20:14 ` Stefan Beller
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Beller @ 2016-06-21 20:14 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, git@vger.kernel.org
On Tue, Jun 21, 2016 at 12:38 PM, Jeff King <peff@peff.net> wrote:
> On Tue, Jun 21, 2016 at 12:18:29PM -0700, Junio C Hamano wrote:
>
>> Stefan Beller <sbeller@google.com> writes:
>>
>> > Unlike the prior patch we would not want this patch to fall through
>> > to origin/maint fast, but allow cooking?
>>
>> I do not see anything that makes this treated differently from the
>> other fix. The only difference in behaviour is that "lines" file is
>> now created at the root level of the trash repository's working tree
>> instead of tested clones', and I do not think any test depends on
>> the number of untracked paths in the trash working tree or tries to
>> make sure a file called "lines" is not in there.
>
> I think it is only that the other patch is actually fixing something,
> whereas this is cleanup. So the cost/benefit equation is different. I
> agree neither is high-risk and a test cleanup is generally OK for maint
> (the other is a serious-ish regression IMHO).
I agree on the cost/benefit equation being different. I considered this patch
a "normal risk" thing, which by our standards is not going through to maint
directly, but is cooked at various heat levels before.
>
>> Having said that, I wonder if we want further reduction of the
>> repetition. Each test except "setup" in this script does an
>> identical thing with very small set of parameters:
>>
>> - make sure super_clone will be removed when done.
>> - clone file://$pwd/. to super_clone but with different set of options.
>> - check the commits in super_clone and super_clone/sub.
>>
>> So, the above would ideally become something like
>>
>> do_test 3 3 --recurse-submodules
>>
>> where the helper would look like
>>
>> do_test () {
>> cnt_super=$1 cnt_sub=$2 &&
>> shift 2 &&
>> test_when_finished "rm -fr super_clone" &&
>> git clone "$@" "file://$pwd/." super_clone &&
>> git -C super_clone log --oneline >lines &&
>> test_line_count = $cnt_super lines &&
>> git -C super_clone/sub log --oneline >lines &&
>> test_line_count = $cnt_sub lines
>> }
>>
>> Would it rob too much flexibility from future tests to be added to
>> this script if we did it that way?
>
> I think that's an improvement, too. Even if we add further tests, they
> don't have to follow the same format. I would give the function a better
> name than "do_test" though. :P
I thought about implementing this, but I was unsure how much flexibility it
is robbing, as we don't know in which direction we're going to extend the
tests if at all. (Are we testing more options or do we want to inject more
commands like "git submodule update --keep-configured-depth" ?
That kept me away from doing the super short do_test)
Thanks,
Stefan
>
> -Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-06-21 20:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-20 17:21 [PATCH] t5614: don't use subshells Stefan Beller
2016-06-21 19:18 ` Junio C Hamano
2016-06-21 19:38 ` Jeff King
2016-06-21 20:14 ` Stefan Beller
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).