Fix special characters in file names #388
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check list
Description
Git escapes special characters in it's output when
core.quotePath
is true or unset. Git always expects unquoted file paths as input. This leads to issues when we consume output from git and use it to build input for other git commands. This commit ensures we always feed unqoted paths to git commands. The_forgit_list_files
function is introduced to handle usage of git ls-files with the -z flag, which ensures unquoted paths. It replaces the direct calls to git ls-files in_forgit_reset_head
,_forgit_stash_push
and_forgit_checkout_file
.In
_forgit_add
the current approach of using colors to separate unstaged from staged files is replaced with a call to_forgit_ls_files
with the appropriate flags to only list unstaged files.In
_git_reset_head
the -z option is added to the git diff command to ensure unqoted paths.Since
git clean
does not support the -z flag, we disablecore.quotePath
by passing a configuration parameter in_forgit_clean
.This fixes #325
Note
This PR is based on #386. I will request reviews once #386 has been merged.
Type of change
Test environment