andy-5 / wslgit

Use Git installed in Bash on Windows/Windows Subsystem for Linux (WSL) from Windows and Visual Studio Code (VSCode)
MIT License
1.19k stars 59 forks source link

Newline not escaped for non-interactive shell #73

Closed carlolars closed 5 years ago

carlolars commented 5 years ago

For example, in VSCode, when doing 'Stage Selected Ranges' a newline is present in the sha1 argument to git update-index, which cause the last argument to be interpreted as a new command:

> git hash-object --stdin -w --path readme.txt
> git ls-tree -l HEAD -- readme.txt
> git update-index --cacheinfo 100644 34d84665cf8b0b17044053c861f3bbbf06590033
 readme.txt
error: option 'cacheinfo' expects <mode>,<sha1>,<path>
usage: git update-index [<options>] [--] [<file>...]

    -q                    continue refresh even when index needs update
[...]
    --no-fsmonitor-valid  clear fsmonitor valid bit

/bin/bash: line 1: readme.txt: command not found

(The newline is actually coming from the output of git hash-object, so it is not a VSCode problem.)