summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonid Volnitsky <Leonid@Volnitsky.com>2012-07-07 23:42:43 +0300
committerLeonid Volnitsky <Leonid@Volnitsky.com>2012-07-07 23:42:43 +0300
commit7bcdb1a7366ef18b3fee5c7a6b26bfc2ff4e66db (patch)
treeaf3d6117344bb46f70164aa2d93582ca57fc5b64
parentdo not display "=" before rawhex if there is freshness indicator (diff)
downloadgit-prompt-7bcdb1a7366ef18b3fee5c7a6b26bfc2ff4e66db.tar.gz
git-prompt-7bcdb1a7366ef18b3fee5c7a6b26bfc2ff4e66db.tar.bz2
git-prompt-7bcdb1a7366ef18b3fee5c7a6b26bfc2ff4e66db.zip
workaround for git status --porcelain quoting bug
-rwxr-xr-xgit-prompt.sh14
1 files 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
'
)"