Skip to content

Problems resolving GIT_EDITOR in paths with spaces #1361

@tmssngr

Description

@tmssngr
  • 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?
$ git --version --build-options

git version 2.15.0.windows.1
built from commit: ed3d106bc93775b62b3860176d7501e079a089b9
sizeof-long: 4
machine: x86
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.15063]
  • What options did you set as part of the installation? Or did you 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

none
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Just unpacked the portable 7z-bundle to a path with spaces, here "C:\Git Windows"

Details

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

Plain cmd

@REM we now create a tiny script in a path with spaces, the content does not
@REM matter but should do no harm
mkdir "path with space"
echo echo 'hello' > "path with space\editor.cmd"
@REM ... set GIT_EDITOR without spaces
set GIT_EDITOR=editor.cmd
@REM but instead add the script directory to PATH
set PATH=%PATH%;%CD%\path with space

@REM we check that it still works
call editor.cmd

@REM Now create a repository
mkdir "repository with space"
git init "%CD%\repository with space"
cd "repository with space"

@REM add a single revision so it is easier to work with this repository
git commit --allow-empty -m "initial, empty commit"

@REM and add two files in two commits
echo file 1 > file1.txt
git add -- file1.txt
git commit -m "added file1.txt"

echo file 2 > file2.txt
git add -- file2.txt
git commit -m "added file2.txt"

@REM Now try to start the interactive rebase
git rebase --interactive HEAD~2
  • What did you expect to occur after running these commands?

The configured GIT_EDITOR should have been invoked

  • What actually happened instead?
C:\temp\a\repository with space>git rebase --interactive HEAD~2
'C:\temp\a\path' is not recognized as an internal or external command,
operable program or batch file.
Could not execute editor

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