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

Re: [PATCH 4/4] remote: check branch names

From
Pphillip.wood123@gmail.com <phillip.wood123@gmail.com>
Date
Sep 18, 2024, 13:18 UTC
Message-ID
<82a08e44-3822-4a26-ad09-4ca1a9b44c11@gmail.com>
In-Reply-To
<xmqqy13vxx3m.fsf@gitster.g>
On 13/09/2024 18:49, Junio C Hamano wrote:
Show 8 quoted lines
> phillip.wood123@gmail.com writes:
> 
>> Thanks for the patch, I'll re-roll based on that. I wonder if we
>> really want to support "@{-N}" when setting remote tracking branches
>> though - should we be using INTERPRET_BRANCH_REMOTE instead when
>> calling strbuf_branchname()?
> 
> Perhaps.  Users try to use "-" in surprising places, though ;-)
strbuf_check_branch_ref() already rejects "-".

INTERPRET_BRANCH_REMOTE supports @{upstream} which might be useful but then we will need to check it refers to the correct remote and expand it when setting the fetch refspec so a boolean function to check if a name is acceptable is insufficient. Given that "git remote set-branches" has only ever supported "real" branch names and patterns on the command line and no-one has complained I wonder if we're better off doing something like

	if (strbuf_check_branch_ref(&buf, branch_name) ||
	    strcmp(buf.buf + 11, branch_name))
		error(_("invalid branch name '%s'", branch_name));
where the "buf.buf + 11" skips "refs/heads/"
Best Wishes
Phillip
Previous: Junio C HamanoNext: Junio C Hamano
Message 21 of 22 in “remote: branch setting fixes”
  1. 0/4 remote: branch setting fixesPhillip Wood via GitGitGadget, Sep 11, 2024
  2. 1/4 remote: fix set-branches when no branches are setPhillip Wood via GitGitGadget, Sep 11, 2024
  3. Junio C HamanoSep 11, 2024
  4. Patrick SteinhardtSep 12, 2024
  5. 2/4 remote: print an error if refspec cannot be removedPhillip Wood via GitGitGadget, Sep 11, 2024
  6. Junio C HamanoSep 11, 2024
  7. Patrick SteinhardtSep 12, 2024
  8. Junio C HamanoSep 12, 2024
  9. Patrick SteinhardtSep 13, 2024
  10. phillip.wood123@gmail.comSep 13, 2024
  11. Junio C HamanoSep 13, 2024
  12. 3/4 remote add: use strvec to store tracking branchesPhillip Wood via GitGitGadget, Sep 11, 2024
  13. Junio C HamanoSep 11, 2024
  14. Patrick SteinhardtSep 12, 2024
  15. 4/4 remote: check branch namesPhillip Wood via GitGitGadget, Sep 11, 2024
  16. Junio C HamanoSep 11, 2024
  17. Patrick SteinhardtSep 12, 2024
  18. Junio C HamanoSep 12, 2024
  19. phillip.wood123@gmail.comSep 13, 2024
  20. Junio C HamanoSep 13, 2024
  21. phillip.wood123@gmail.comSep 18, 2024
  22. Junio C HamanoSep 18, 2024

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.