git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date
Mar 12, 2009, 15:20 UTC
Message-ID
<20090312152039.GA15626@pengutronix.de>
In-Reply-To
<78BA729B-0026-45D0-96FC-330700519AAB@dartmouth.edu>
Hello Brian, hello Junio,
On Thu, Mar 12, 2009 at 11:00:00AM -0400, Brian Campbell wrote:
Show 13 quoted lines
> On Mar 12, 2009, at 3:45 AM, Uwe Kleine-König wrote:
>
>>> - 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.
>
> Yes, you're right, this is a problem.
>
>>> To fix these, you might want to do something like:
>>>
>>> 	if head_=$(git symbolic-ref HEAD)
Shouldn't git symbolic-ref -q HEAD be used here?
Show 14 quoted lines
>>>        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

How do I distinguish between a detached HEAD and another error? I have the feeling that git symbolic-ref -q HEAD should exit(0) with a detached HEAD.

Show 10 quoted lines
>> Thanks Junio and Brian.
>>
>> Brian, do you update the series?
>
> Sure, I'll send an updated patch.
>
> I'm thinking that for the detached HEAD case, this function should die  
> with a message about not being on a valid branch, and then the call site 
> in tg-summary that doesn't care about being on a valid branch should 
> ignore the error and leave curname empty. Does that sound about right? 
mmh, I would return "" and let the caller handle that.
> Also, has anyone considered writing a test suite for TopGit?

Yes, but I didn't found the time for that until now. If you'd volunteer that would be very welcome.

IMHO we should reuse as much as possible from git.git. For me even requiring a git.git checkout to use its files would be OK. I consider that even better then duplicating the relevant files.

Best regards Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
Peiner Strasse 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686              | Fax:   +49-5121-206917-5555 |
Previous: Brian CampbellNext: martin f krafft
Message 6 of 12 in “[TopGit] Portability: Use tr instead of sed for translating spaces to newlines”
  1. 1/2 [TopGit] Portability: Use tr instead of sed for translating spaces to newlinesBrian Campbell, Mar 12, 2009
  2. 2/2 [TopGit] Portability: Don't use alternation ("|") in sed regular expressionsBrian Campbell, Mar 12, 2009
  3. Junio C HamanoMar 12, 2009
  4. Uwe Kleine-KönigMar 12, 2009
  5. Brian CampbellMar 12, 2009
  6. Uwe Kleine-KönigMar 12, 2009
  7. martin f krafftMar 12, 2009
  8. Junio C HamanoMar 14, 2009
  9. Uwe Kleine-KönigMar 14, 2009
  10. Brian CampbellMar 12, 2009
  11. Uwe Kleine-KönigMar 12, 2009
  12. Uwe Kleine-KönigMar 12, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.