summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonid Volnitsky <Leonid@Volnitsky.com>2009-02-20 13:52:53 +0200
committerLeonid Volnitsky <Leonid@Volnitsky.com>2009-02-20 13:52:53 +0200
commitb19f742bcaa573d2e0f37e35dc6272a6aa419b8c (patch)
treed3ea4907a8b5eac0a5327372f4f6b063ef673cc9
parentadded: pick hostname color from hostname checksum (diff)
downloadgit-prompt-b19f742bcaa573d2e0f37e35dc6272a6aa419b8c.tar.gz
git-prompt-b19f742bcaa573d2e0f37e35dc6272a6aa419b8c.tar.bz2
git-prompt-b19f742bcaa573d2e0f37e35dc6272a6aa419b8c.zip
fixed space-in-filename bug (again)
[GitHub] aevernon: I found a bug in git-prompt. If you have a filename containing a space in a Git working directory, git-prompt gets confused and tries to evaluate as a command the part of the filename after the space. For example, if you are in a Git working directory and run touch Test\ File you will see the message bash: File: command not found
-rw-r--r--git-prompt.sh19
1 files changed, 12 insertions, 7 deletions
diff --git a/git-prompt.sh b/git-prompt.sh
index c3c5e21..699d15f 100644
--- a/git-prompt.sh
+++ b/git-prompt.sh
@@ -291,21 +291,26 @@ parse_git_dir() {
s/^# On branch /branch=/p
s/^nothing to commit (working directory clean)/clean=clean/p
s/^# Initial commit/init=init/p
+
+ s/^# \.\./: SKIP/
+
/^# Untracked files:/,/^[^#]/{
s/^# Untracked files:/untracked=untracked;/p
- s/^# \([^.]\)/untracked_files[${#untracked_files[@]}+1]=\"\1\"/p
+ s/^# \(.*\)/untracked_files[${#untracked_files[@]}+1]=\\"\1\\"/p
}
+
/^# Changed but not updated:/,/^# [A-Z]/ {
s/^# Changed but not updated:/modified=modified;/p
- s/^# modified: \([^.]\)/modified_files[${#modified_files[@]}+1]=\"\1\"/p
- s/^# unmerged: \([^.]\)/modified_files[${#modified_files[@]}+1]=\"\1\"/p
+ s/^# modified: \(.*\)/modified_files[${#modified_files[@]}+1]=\"\1\"/p
+ s/^# unmerged: \(.*\)/modified_files[${#modified_files[@]}+1]=\"\1\"/p
}
+
/^# Changes to be committed:/,/^# [A-Z]/ {
s/^# Changes to be committed:/added=added;/p
- s/^# modified: \([^.]\)/added_files[${#added_files[@]}+1]=\"\1\"/p
- s/^# new file: \([^.]\)/added_files[${#added_files[@]}+1]=\"\1\"/p
- s/^# renamed:[^>]*> \([^.]\)/added_files[${#added_files[@]}+1]=\"\1\"/p
- s/^# copied:[^>]*> \([^.]\)/added_files[${#added_files[@]}+1]=\"\1\"/p
+ s/^# modified: \(.*\)/added_files[${#added_files[@]}+1]=\"\1\"/p
+ s/^# new file: \(.*\)/added_files[${#added_files[@]}+1]=\"\1\"/p
+ s/^# renamed:[^>]*> \(.*\)/added_files[${#added_files[@]}+1]=\"\1\"/p
+ s/^# copied:[^>]*> \(.*\)/added_files[${#added_files[@]}+1]=\"\1\"/p
}
'
`