Permalink
Browse files

Sanity check for the case we are not in a git branch.

  • Loading branch information...
1 parent 2a8ed61 commit cbd66b8329064479ac15d9c88197ae302721ee61 @wayneeseguin wayneeseguin committed Mar 31, 2011
Showing with 5 additions and 2 deletions.
  1. +5 −2 contrib/ps1_functions
View
@@ -40,10 +40,13 @@ ps1_git()
if ! command -v git >/dev/null 2>&1 ; then
printf " \033[1;37m\033[41m[git not found]\033[m "
- exit 0
+ return 0
fi
- branch=$(git symbolic-ref -q HEAD)
+ branch=$(git symbolic-ref -q HEAD 2>/dev/null)
+ if [[ $? -gt 0 ]] ; then
+ return 0 # Not in a git repo, no need to continue.
+ fi
branch=${branch##refs/heads/}
# Now we display the branch.

0 comments on commit cbd66b8

Please sign in to comment.