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

Re: [PATCH] stash: strip "refs/heads/" with skip_prefix

From
Glen Choo <chooglen@google.com>
Date
Feb 24, 2022, 07:13 UTC
Message-ID
<kl6lsfs84u06.fsf@chooglen-macbookpro.roam.corp.google.com>
In-Reply-To
<xmqq7dao1e5m.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 13 quoted lines
> Glen Choo <chooglen@google.com> writes:
>
>>  	branch_ref = resolve_ref_unsafe("HEAD", 0, NULL, &flags);
>>  	if (flags & REF_ISSYMREF)
>> -		branch_name = strrchr(branch_ref, '/') + 1;
>> +		skip_prefix(branch_ref, "refs/heads/", &branch_name);
>
> The branch_name variable is initialized to a constant string "(no branch)",
> so if HEAD is poihnting elsewhere (which you could do manually),
> skip_prefix() would fail and leave branch_name intact, which would
> give us the desirable outcome, too.
>
> Looking good.

Hm, did we ever pick this up? I dug through the old "What's Cooking" mails and didn't find any mention of this.

Admittedly, this dropped off my radar until performance review season reminded me of this. Though now that I say this, it sounds like I want this for the sake of performance review :p

(Which is not the case btw, I just want to scratch my own itch :))
Previous: Junio C Hamano
Message 5 of 5 in “[BUG] git-stash does not handle branch name with slash correctly”
  1. Daniel HahlerNov 10, 2021
  2. Jeff KingNov 10, 2021
  3. stash: strip "refs/heads/" with skip_prefixGlen Choo, Jan 24, 2022
  4. Junio C HamanoJan 25, 2022
  5. Glen ChooFeb 24, 2022

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.