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

Re: [PATCH] disallow refs containing successive slashes

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 12, 2009, 00:31 UTC
Message-ID
<20091012003115.GA5782@progeny.tock>
In-Reply-To
<7vbpkdwyo2.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
 
Show 6 quoted lines
> When the users make typoes (e.g. /foo//bar) you can accept the only sane
> correction (e.g. foo/bar) instead of rejecting, since the only thing the
> user can do after getting such a rejection is to correct it to that
> corrected name (e.g. foo/bar) himself and re-issue the command anyway.
> You can push the "hassle" down to the user, or you can fix the tool to
> remove the hassle from the user.

Yes, making check-ref-format stricter without changing its users to massage their input would be a regression.

The problem Jens described is a git-gui bug. In lib/branch_delete.tcl, line 57, the list of deletable branches is populated as follows:

	foreach h [load_all_heads] {
		if {$h ne $current_branch} {
			$w_heads insert end $h
		}
	}

Since slashes coalesce, a user-supplied new branch name is not canonical and checking "$h eq $current_branch" does not actually check if they are the same branch. git-gui should be using the branch name as output by "git check-ref-format --branch" after the branch is created.

But what about other scripts that assume each branch has only one possible name? Maybe they could be forced to fix up the name early on by making check-ref-format reject names with "//" in them and providing a "git check-ref-format --print" to help.

Upside: scripts would complain loudly instead of failing subtly on input
with extra slashes if they forget to use "git check-ref-format --print"
when appropriate.  Downside: users, including the 22 callers of
check_ref_format() in git, would have to be checked and probably changed
to avoid regressions.

Never having made that typo, I find it hard to consider such a change worth the trouble, but it sounds doable.

Regards, Jonathan

Previous: Junio C HamanoNext: Nanako Shiraishi
Message 5 of 17 in “disallow refs containing successive slashes”
  1. disallow refs containing successive slashesJens Lehmann, Oct 10, 2009
  2. Junio C HamanoOct 10, 2009
  3. Jens LehmannOct 11, 2009
  4. Junio C HamanoOct 11, 2009
  5. Jonathan NiederOct 12, 2009
  6. Nanako ShiraishiOct 12, 2009
  7. 0/4 plumbing to help fix git-guiJonathan Nieder, Oct 12, 2009
  8. 1/4 Add tests for git check-ref-formatJonathan Nieder, Oct 12, 2009
  9. 2/4 Documentation: describe check-ref-format --branchJonathan Nieder, Oct 12, 2009
  10. 3/4 git check-ref-format --printJonathan Nieder, Oct 12, 2009
  11. Shawn O. PearceOct 12, 2009
  12. Junio C HamanoOct 12, 2009
  13. Shawn O. PearceOct 12, 2009
  14. Junio C HamanoOct 12, 2009
  15. Jonathan NiederOct 13, 2009
  16. 4/4 check-ref-format: simplify --print implementationJonathan Nieder, Oct 12, 2009
  17. Jonathan NiederOct 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.