From 8546ca362c7a42aff5ff963c26ce22d0bd2f73ea Mon Sep 17 00:00:00 2001 From: Tom Hoover Date: Fri, 2 Mar 2012 22:03:23 -0600 Subject: 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). --- git-prompt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3