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

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

From
Torsten Bögershausen <tboegi@web.de>
Date
Dec 15, 2016, 07:30 UTC
Message-ID
<c8501e28-db8a-5b6e-717c-5bda1e63c2e7@web.de>
In-Reply-To
<787a421b-8b7a-14c5-768f-06c3dc183cf4@kdbg.org>
On 14/12/16 20:37, Johannes Sixt wrote:
Show 30 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.
>
> Fix it by skipping all of the root part, not just a potential drive
> prefix. offset_1st_component takes care of this, see the
> implementation in compat/mingw.c::mingw_offset_1st_component().
>
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
> ---
> Am 14.12.2016 um 18:30 schrieb Jeff King:
>> 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;
>>    }
> Makes a lot of sense! I haven't had an opportunity, though, to test
> on Windows.

I'm not sure, if a conversion should be done here, in this part of code. To my knowledge,

C:\dir1\file is the same as C:/dir1/file and that is handled by windows.

The \\server\share\dir1\file is native to windows, and I can't see good reasons to change '\' into '/' somewhere in Git, when UNC is used.

Cygwin does a translation from //server/share/dir1/file into \\server\share\dir1\file

In other words: The patch looks good as is, and once I get a Windows machine, may be able to do some testing and come up with test cases

<https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx> []

Previous: Johannes SixtNext: Jeff King
Message 5 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.