Re: [PATCH v2 3/3] rebase: rebasing can also be done when HEAD is detached

2017-11-28 Thread Kaartic Sivaraam
On Tue, 2017-11-28 at 11:31 +0900, Junio C Hamano wrote:
> Kaartic Sivaraam  writes:
> 
> > +   if test "$branch_or_commit" = "HEAD" &&
> > +!(git symbolic-ref -q HEAD)
> 
> Did you need a subshell here? 

No. That's a consequence of me not remembering that I would span a sub-
shell with a simple '()' when I was doing that part. (partial
transition from C to shell)


>  Now with a proper test with
> "symbolic-ref -q HEAD", I wonder if you'd need to check if the
> original was named HEAD in the first place (I do not feel strongly
> enough to say that checking is wrong, at least not yet, but the
> above does make me wonder), and instead something like
> 
>   if ! git symbolic-ref -q HEAD
>   then
>   ...
> 
> might be sufficient.  I dunno.
> 

It does  seem you're right. The only thing we would be losing is the
short-circuiting when $branch_or_commit is not HEAD (which I suspect to
be the case most of the time). So, I'm not sure if I should remove the
check (of course, I'll change the check to avoid spawning a sub-shell).


Thanks, 
Kaartic


Re: [PATCH v2 3/3] rebase: rebasing can also be done when HEAD is detached

2017-11-27 Thread Junio C Hamano
Kaartic Sivaraam  writes:

> + if test "$branch_or_commit" = "HEAD" &&
> +  !(git symbolic-ref -q HEAD)

Did you need a subshell here?  Now with a proper test with
"symbolic-ref -q HEAD", I wonder if you'd need to check if the
original was named HEAD in the first place (I do not feel strongly
enough to say that checking is wrong, at least not yet, but the
above does make me wonder), and instead something like

if ! git symbolic-ref -q HEAD
then
...

might be sufficient.  I dunno.

I find what 2/3 and 3/3 want to do quite sensible.  They depend on
1/3, which I find is more a needless churn than a clean-up, which is
unfortunate, though.

Thanks.