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

Re: [PATCH 2/2] Windows: do not treat a path with backslashes as a remote's nick name

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 22, 2017, 11:56 UTC
Message-ID
<alpine.DEB.2.21.1.1705221353570.3610@virtualbox>
In-Reply-To
<6347731f26396b1256070e02376bf3623bfb7102.1495261020.git.j6t@kdbg.org>
Hi Hannes,
On Sat, 20 May 2017, Johannes Sixt wrote:
Show 16 quoted lines
> Fetching from a remote using a native Windows path produces these warnings:
> 
> C:\Temp\gittest>git fetch C:\Temp\gittest
> warning: unable to access '.git/remotes/C:\Temp\gittest': Invalid argument
> warning: unable to access '.git/branches/C:\Temp\gittest': Invalid argument
> From C:\Temp\gittest
>  * branch            HEAD       -> FETCH_HEAD
> 
> The functions that read the branches and remotes files are protected by
> a valid_remote_nick() check. Its implementation does not take Windows
> paths into account, so that the caller simply concatenates the paths,
> leading to the error seen above.
> 
> Use is_dir_sep() to check for both slashes and backslashes on Windows.
> 
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
I like this explanation.
Show 11 quoted lines
> diff --git a/remote.c b/remote.c
> index 9584af366d..9501357c06 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -649,7 +649,10 @@ static int valid_remote_nick(const char *name)
>  {
>  	if (!name[0] || is_dot_or_dotdot(name))
>  		return 0;
> -	return !strchr(name, '/'); /* no slash */
> +	while (*name)
> +		if (is_dir_sep(*name++))	/* no slash */

I understand that you simply kept the comment, yet I have to admit that I find it confusing in the post image. Something like

	/* remote nicknames cannot contain slashes */

(and putting it *above* the `if` line instead of appending it separated by a <tab>) would have made it easier on me.

> +			return 0;
> +	return 1;
>  }
>  
With my suggested change or without it, ACK.

Ciao, Dscho

Previous: Johannes SixtNext: Johannes Schindelin
Message 5 of 19 in “Fix warnings on access of a remote with Windows paths”
  1. 0/2 Fix warnings on access of a remote with Windows pathsJohannes Sixt, May 20, 2017
  2. 1/2 mingw.h: permit arguments with side effects for is_dir_sepJohannes Sixt, May 20, 2017
  3. Johannes SchindelinMay 22, 2017
  4. 2/2 Windows: do not treat a path with backslashes as a remote's nick nameJohannes Sixt, May 20, 2017
  5. Johannes SchindelinMay 22, 2017
  6. Johannes SchindelinMay 22, 2017
  7. Johannes SixtMay 22, 2017
  8. Johannes SchindelinMay 23, 2017
  9. Johannes SixtMay 23, 2017
  10. stefan.naewe@atlas-elektronik.comMay 22, 2017
  11. Johannes SchindelinMay 22, 2017
  12. Johannes SixtMay 22, 2017
  13. Johannes SchindelinMay 23, 2017
  14. Junio C HamanoMay 23, 2017
  15. Johannes SixtMay 24, 2017
  16. 2/2 Windows: do not treat a path with backslashes as a remote's nick nameJohannes Sixt, May 25, 2017
  17. Junio C HamanoMay 25, 2017
  18. 1/2 mingw.h: permit arguments with side effects for is_dir_sepJohannes Sixt, May 22, 2017
  19. 2/2 Windows: do not treat a path with backslashes as a remote's nick nameJohannes Sixt, May 22, 2017

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.