Re: [PATCH 2/2] [TopGit] Portability: Don't use alternation ("|") in sed regular expressions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Brian, hello Junio,

On Wed, Mar 11, 2009 at 11:55:49PM -0700, Junio C Hamano wrote:
> Brian Campbell <brian.p.campbell@xxxxxxxxxxxxx> writes:
> 
> > +current_branch()
> > +{
> > +	echo "$(git symbolic-ref HEAD | sed -e 's#^refs/heads/##' -e 's#^refs/top-bases/##')"
> > +}
> 
> Two micronits.
> 
>  - what happens when you are on a detached HEAD?
The original code had this problem, too, so I would not take this as a
stopper for the patch.  There are some other locations that suffer from
the same problem.  That's already on my todo list.  So I don't care much
here.
 
>  - You will be utterly confused by a local branch whose name is
>    "refs/top-bases/foo"
You mean a branch that has the full name refs/heads/refs/top-bases/foo?
Well OK, valid concern.

> To fix these, you might want to do something like:
> 
> 	if head_=$(git symbolic-ref HEAD)
>         then
>                 case "$head_" in
>                 refs/heads/*)
>                         echo "${head_#refs/heads/}"
>                         ;;
>                 refs/top-bases/*)
>                         echo "${head_#refs/top-bases/}"
>                         ;;
>                 *)
>                         echo "$head_"
>                         ;;
>                 esac
> 	else
>         	whatever you want to do on a detached HEAD
> 	fi
Thanks Junio and Brian.

Brian, do you update the series?

Best regards
Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux