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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 25, 2022, 07:13 UTC
Message-ID
<xmqq7dao1e5m.fsf@gitster.g>
In-Reply-To
<20220124205342.41450-1-chooglen@google.com>
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.
Previous: Glen ChooNext: Glen Choo
Message 4 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.