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

Re: [PATCH] fix pushing to //server/share/dir paths on Windows

From
Jeff King <peff@peff.net>
Date
Dec 14, 2016, 17:30 UTC
Message-ID
<20161214173034.inbyakdykjv5j7ua@sigill.intra.peff.net>
In-Reply-To
<2ff2613c-47da-a780-5d38-93e16cb16328@kdbg.org>
On Tue, Dec 13, 2016 at 10:32:01PM +0100, Johannes Sixt wrote:
Show 9 quoted lines
> normalize_path_copy() is not prepared to keep the double-slash of a
> //server/share/dir kind of path, but treats it like a regular POSIX
> style path and transforms it to /server/share/dir.
> 
> The bug manifests when 'git push //server/share/dir master' is run,
> because tmp_objdir_add_as_alternate() uses the path in normalized
> form when it registers the quarantine object database via
> link_alt_odb_entries(). Needless to say that the directory cannot be
> accessed using the wrongly normalized path.

Thanks for digging this up! I had a feeling that the problem was going to be in the underlying path code, but I didn't want to just pass the buck without evidence. :)

Show 10 quoted lines
> -	if (is_dir_sep(*src)) {
> +	/*
> +	 * Handle initial part of absolute path: "/", "C:/", "\\server\share/".
> +	 */
> +	offset = offset_1st_component(src);
> +	if (offset) {
> +		/* Convert the trailing separator to '/' on Windows. */
> +		memcpy(dst, src, offset - 1);
> +		dst += offset - 1;
>  		*dst++ = '/';

Hmm. So this is the "change-of-behavior" bit. Would it be reasonable to write:

  /* Copy initial part of absolute path, converting separators on Windows */
  const char *end = src + offset_1st_component(src);
  while (src < end) {
	  char c = *src++;
	  if (c == '\\')
		  c = '/';
	  *dst++ = c;
  }

? I'm not sure if it's wrong to convert backslashes in that first component or not (but certainly we were before). I don't think we'd need is_dir_sep() in that "if()", because we can leave slashes as-is. But maybe it would make the code easier to read.

-Peff
Previous: Junio C HamanoNext: Johannes Sixt
Message 3 of 8 in “fix pushing to //server/share/dir paths on Windows”
  1. fix pushing to //server/share/dir paths on WindowsJohannes Sixt, Dec 13, 2016
  2. Junio C HamanoDec 13, 2016
  3. Jeff KingDec 14, 2016
  4. fix pushing to //server/share/dir on WindowsJohannes Sixt, Dec 14, 2016
  5. Torsten BögershausenDec 15, 2016
  6. Jeff KingDec 15, 2016
  7. Junio C HamanoDec 15, 2016
  8. Johannes SchindelinDec 19, 2016

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.