Skip to content

Unclear error handling when trying to create a branch with Windows filesystem disallowed characters < > | " #2904

Open
@whitneyschmidt

Description

@whitneyschmidt
  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?

64 bit

$ git --version --build-options
git version 2.29.2.windows.2
cpu: x86_64
built from commit: 3464b98ce6803c98bf8fb34390cd150d66e4a0d3
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?

Windows 10 Enterprise 20H2

$ cmd.exe /c ver

Microsoft Windows [Version 10.0.19042.630]
  • What options did you set as part of the installation? Or did you choose the
    defaults?

Choose the defaults.

# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

$ cat install-options.txt
Editor Option: VIM
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Core
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable Pseudo Console Support: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

** insert your response here **

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Git for Windows 👍

$ git checkout -b "<"
fatal: cannot lock ref 'refs/heads/<': Unable to create 'C:/Users/whschm/source/repos/TestRepo/.git/refs/heads/<.lock': Invalid argument

$ git checkout -b "hi>"
fatal: cannot lock ref 'refs/heads/hi>': Unable to create 'C:/Users/whschm/source/repos/TestRepo/.git/refs/heads/hi>.lock': Invalid argument

$ git checkout -b ":"
fatal: ':' is not a valid branch name.
  • What did you expect to occur after running these commands?

A nicer error message, like the one for ":" that indicates that there's an invalid character in the branch name.

  • What actually happened instead?
fatal: cannot lock ref 'refs/heads/hi>': Unable to create 'C:/Users/whschm/source/repos/TestRepo/.git/refs/heads/hi>.lock': Invalid argument

< and > are both disallowed characters for file names in the windows file system, so this seems likely to be related to how Git for Windows handles these characters.

The git (Linux) repo doesn't sanitize input for < or > and the man page doesn't indicate that either of these are invalid characters.

It would be great to have better error handling/user experience for this case!

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions