summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hoover <tom@hisword.net>2012-03-02 22:03:23 -0600
committerTom Hoover <tom@hisword.net>2012-03-02 22:03:23 -0600
commit8546ca362c7a42aff5ff963c26ce22d0bd2f73ea (patch)
treed874609b3e0eb3689bb23ff5d32411f452b41446
parentfix for enable/disable_set_shell_label (diff)
downloadgit-prompt-8546ca362c7a42aff5ff963c26ce22d0bd2f73ea.tar.gz
git-prompt-8546ca362c7a42aff5ff963c26ce22d0bd2f73ea.tar.bz2
git-prompt-8546ca362c7a42aff5ff963c26ce22d0bd2f73ea.zip
added quotation marks around $git_dir/HEAD to prevent "detached" message from appearing in the prompt when $git_dir includes space character(s)
For example, assume a git repository located at /Volumes/Macintosh HD/Users/tom/src/myrepository: - this bug does not appear when the working directory is the root of the git repository ( e.g. /Volumes/Macintosh HD/Users/tom/src/myrepository ), as $git_dir returns ".git" - the bug only appears if the directory is changed to one other than the root of the repository ( e.g. /Volumes/Macintosh HD/Users/tom/src/myrepository/DIRECTORY ), as $git_dir will then return the full path "/Volumes/Macintosh HD/Users/tom/src/myrepository/.git". The space between "Macintosh" and "HD" will cause 'grep "^ref:" $git_dir/HEAD' to fail. Adding quotation marks around $git_dir/HEAD allows the grep test to succeed, even when the path includes space character(s).
-rwxr-xr-xgit-prompt.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/git-prompt.sh b/git-prompt.sh
index 41aa587..02e6c5a 100755
--- a/git-prompt.sh
+++ b/git-prompt.sh
@@ -465,7 +465,7 @@ parse_git_status() {
'
)"
- if ! grep -q "^ref:" $git_dir/HEAD 2>/dev/null; then
+ if ! grep -q "^ref:" "$git_dir/HEAD" 2>/dev/null; then
detached=detached
fi