On Sun, 18 Oct 2020 at 21:09, Phillip Wood <phillip.wood123@xxxxxxxxx> wrote: > > Hi Charvi > > Congratulations on posting your first patch series. > > On 17/10/2020 08:54, Charvi Mendiratta wrote: > > Avoid using `cd` outside of subshells since, if the test fails, there is no guarantee that the current working directory is the expected one, which may cause subsequent tests to run in the wrong directory. > > That is an accurate description of why we want to avoid using `cd` > outside of subshells. However this conversion is converting `cd` inside > a subshell to use `git -C`. I think that is worthwhile as it avoids > having to use a subshell but the description should say explain that the > conversion is desirable to avoid the cost of starting a subshell as the > original test does not suffer from the problem described in your commit > message. > Thank you Philip, for corrections . I somewhat able to understand that commit message should be " avoid using cd inside the subshells " because running a shell script itselfs starts a new subshell, please correct me if I am wrong . But still I am unable to get that why you mentioned the description as "cost of starting a new subshell " . Will this not be the same subshell ? > Best Wishes > > Phillip > > > > > Signed-off-by: Charvi Mendiratta <charvi077@xxxxxxxxx> > > --- > > t/t7201-co.sh | 10 ++-------- > > 1 file changed, 2 insertions(+), 8 deletions(-) > > > > diff --git a/t/t7201-co.sh b/t/t7201-co.sh > > index 74553f991b..5898182fd2 100755 > > --- a/t/t7201-co.sh > > +++ b/t/t7201-co.sh > > @@ -339,10 +339,7 @@ test_expect_success 'switch branches while in subdirectory' ' > > git checkout master && > > > > mkdir subs && > > - ( > > - cd subs && > > - git checkout side > > - ) && Is there any specific meaning of writing these above two commands in parentheses . Will this not work the same without it ? > > + git -C subs checkout side && > > ! test -f subs/one && > > rm -fr subs > > ' > > @@ -357,10 +354,7 @@ test_expect_success 'checkout specific path while in subdirectory' ' > > > > git checkout master && > > mkdir -p subs && > > - ( > > - cd subs && > > - git checkout side -- bero > > - ) && > > + git -C subs checkout side -- bero && > > test -f subs/bero > > ' > > > > Thanks and Regards , Charvi