git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jordan DE GEA <jordan.de-gea@grenoble-inp.org>,
	git@vger.kernel.org, erwan.mathoniere@grenoble-inp.org,
	samuel.groot@grenoble-inp.org, tom.russello@grenoble-inp.org,
	Jordan DE GEA <jordan.de-gea@ensimag.grenoble-inp.fr>
Subject: Re: [PATCH] worktree: allow "-" short-hand for @{-1} in add command
Date: Fri, 27 May 2016 11:18:43 +0200	[thread overview]
Message-ID: <vpqvb1zrh8s.fsf@anie.imag.fr> (raw)
In-Reply-To: <xmqqshx4vedr.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Thu, 26 May 2016 11:54:40 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> Jordan DE GEA <jordan.de-gea@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.

> 	git -C short-hand rev-parse --symbolic-full-name HEAD >actual &&

Indeed, git -C is an even better way to say "cd .. && git ..."

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

  reply	other threads:[~2016-05-27  9:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <vpqshx5cb51.fsf@anie.imag.fr>
2016-05-26 11:54 ` [PATCH] worktree: allow "-" short-hand for @{-1} in add command Jordan DE GEA
2016-05-26 18:54   ` Junio C Hamano
2016-05-27  9:18     ` Matthieu Moy [this message]
2016-05-27 17:52       ` Junio C Hamano
2016-05-27 12:43     ` Jordan DE GEA
2016-05-27 13:17       ` [PATCH v2] " Jordan DE GEA
2016-05-27 18:01       ` [PATCH] " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vpqvb1zrh8s.fsf@anie.imag.fr \
    --to=matthieu.moy@grenoble-inp.fr \
    --cc=erwan.mathoniere@grenoble-inp.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jordan.de-gea@ensimag.grenoble-inp.fr \
    --cc=jordan.de-gea@grenoble-inp.org \
    --cc=samuel.groot@grenoble-inp.org \
    --cc=tom.russello@grenoble-inp.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).