From 7bcdb1a7366ef18b3fee5c7a6b26bfc2ff4e66db Mon Sep 17 00:00:00 2001 From: Leonid Volnitsky Date: Sat, 7 Jul 2012 23:42:43 +0300 Subject: workaround for git status --porcelain quoting bug --- git-prompt.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/git-prompt.sh b/git-prompt.sh index cb3c296..7acda17 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -443,13 +443,23 @@ parse_git_status() { )" # porcelain file list - # TODO: sed-less -- http://tldp.org/LDP/abs/html/arrays.html -- Example 27-5 + # TODO: sed-less -- http://tldp.org/LDP/abs/html/arrays.html -- Example 27-5 + + # git bug: (was reported to git@vger.kernel.org ) + # echo 1 > "with space" + # git status --porcelain + # ?? with space <------------ NO QOUTES + # git add with\ space + # git status --porcelain + # A "with space" <------------- WITH QOUTES + eval " $( git status --porcelain 2>/dev/null | sed -n ' s/^[MARC]. \(.*\)/ added=added; [[ \" ${added_files[*]} \" =~ \1 ]] || added_files[${#added_files[@]}]=\1/p s/^.[MAU] \(.*\)/ modified=modified; [[ \" ${modified_files[*]} \" =~ \1 ]] || modified_files[${#modified_files[@]}]=\1/p - s/^?? \(.*\)/ untracked=untracked; [[ \" ${untracked_files[*]} \" =~ \1 ]] || untracked_files[${#untracked_files[@]}]=\1/p + s/^?? \([a-zA-Z_.=:]*\)$/ untracked=untracked; [[ \" ${untracked_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p + s/^?? \(.*\)$/ untracked=untracked; [[ \" ${untracked_files[*]} \" =~ \" \1 \" ]] || untracked_files[${#untracked_files[@]}]=\"\1\"/p ' )" -- cgit v1.2.3