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

Re: Bug: Pathspec parsing on Windows fails when branch specified

From
Johannes Sixt <j6t@kdbg.org>
Date
Nov 20, 2013, 22:12 UTC
Message-ID
<528D33D5.4090507@kdbg.org>
In-Reply-To
<CAM8h_A_zfX4U8hGxiw3_79zMZXmcTN3CPRUcrtsQTQdD4RaMhQ@mail.gmail.com>
Am 20.11.2013 22:09, schrieb Eris Belew:
Show 24 quoted lines
> System: Windows Server 2008 R2
> Git: git version 1.8.4.msysgit.0
> Shell: Powershell V3 (No third-party modules loaded)
> 
> Summary:
>   When specifying a pathspec including a branch/commit, path separator
> characters are not translated. Since tab-completion in windows shells (ex:
> CMD, PowerShell, not unix-style shells running on windows) uses the windows
> path separator, and other git commands work fine with the windows path
> separator, the expected behavior would be to translate for me.
> 
> Reproduction:
>     git diff BRANCH:path\to\file path\to\file
> 
> Result:
>     fatal: Path 'path\to\file' does not exist in 'BRANCH'
> 
> Expected:
>     Normal diff operation
> 
> Workaround:
>     Manually convert pathspec. Examples of working command:
>         git diff BRANCH:path/to/file path\to\otherfile
>         git diff BRANCH:path/to/file path/to/otherfile

That's not a bug, it is expected behavior. "BRANCH:path/to/file" is not "file on disk" syntax, but Git's syntax to reference a particular object in the database. For this reason, forward-slashes are mandated; there is no option to use backslashes in this case.

Backslashes could actually be part of directory and file names in the database. It would be impossible to check out a tree with such names on Windows, obviously.

-- Hannes
Previous: Eris Belew
Message 2 of 2 in “Bug: Pathspec parsing on Windows fails when branch specified”
  1. Eris BelewNov 20, 2013
  2. Johannes SixtNov 20, 2013

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.