mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-14 17:26:15 -04:00
fix: handle backslashes in filenames in _forgit_worktree_changes
Git escapes backslashes with `git status` even when `core.quotepath=false` is set. Use `--porcelain -z` with `git status` as a more robust approach to fix this. Fixes #467
This commit is contained in:
parent
1bc93a2c3a
commit
2c17635d4f
|
|
@ -224,7 +224,8 @@ _forgit_worktree_changes() {
|
|||
untracked=$(git config --get-color color.status.untracked red)
|
||||
show_untracked=$(git config status.showUntrackedFiles)
|
||||
|
||||
git -c color.status=always -c status.relativePaths=true -c core.quotePath=false status -s --untracked="${show_untracked:-all}" |
|
||||
git -c color.status=always -c status.relativePaths=true status --porcelain -zs --untracked="${show_untracked:-all}" |
|
||||
tr '\0' '\n' |
|
||||
grep -F -e "$changed" -e "$unmerged" -e "$untracked" |
|
||||
sed -E 's/^(..[^[:space:]]*)[[:space:]]+(.*)$/[\1] \2/'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
git add "staged file.txt"
|
||||
|
||||
touch "untracked_file.txt"
|
||||
touch 'untracked_with_\backslash'
|
||||
}
|
||||
|
||||
function test_forgit_worktree_changes_contains_modified() {
|
||||
|
|
@ -56,3 +57,11 @@
|
|||
|
||||
assert_not_contains "tracked file.txt" "$output"
|
||||
}
|
||||
|
||||
function test_forgit_worktree_changes_supports_backslashes() {
|
||||
local output
|
||||
|
||||
output=$(_forgit_worktree_changes)
|
||||
|
||||
assert_contains 'untracked_with_\backslash' "$output"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue