Matthieu Moy <matthieu....@grenoble-inp.fr> writes:

> Junio C Hamano <gits...@pobox.com> writes:
>
>> Jordan DE GEA <jordan.de-...@grenoble-inp.org> writes:
>>
>>> +   branch=$(cd short-hand && git rev-parse --symbolic-full-name HEAD) &&
>>> +   test "$branch" = refs/heads/newbranch &&
>>> +   cd ..
>>
>> If any of the command between "cd short-hand" and "cd .." failed,
>> after correcting the broken &&-chain, the next test will end up
>> running in short-hand directory, which it is not expecting.  A
>> canonical way to avoid this problem is to replace the above with:
>>
>>      ...
>>         git worktree add short-hand - &&
>>         (
>>              cd short-hand &&
>>                 ...
>>                 test "$branch" = refs/heads/newbranch
>>      )
>
> Actually, $(...) implicitly does a subshell, so the "cd .." was just
> useless.

You trimmed my message a bit too aggressively while composing your
response, and I think that is what ended up confusing you.  

Here is what I wrote:

| > +   cd short-hand &&
| > +   test $(git rev-parse --symbolic-full-name HEAD) = "refs/heads/newbranch"
| 
| Broken &&-chain.
| 
| > +   branch=$(cd short-hand && git rev-parse --symbolic-full-name HEAD) &&
| > +   test "$branch" = refs/heads/newbranch &&
| > +   cd ..
| 
| If any of the command between "cd short-hand" and "cd .." failed,
| ...

The problematic "cd short-hand" is the one a few lines above where
you started quoting, not the one you saw in the $().

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to