Browse code

Only calling git symbolic-ref HEAD when we are in a .git directory

Robby Russell authored on 31/08/2009 at 20:54:50
Showing 1 changed files
... ...
@@ -1,9 +1,8 @@
1 1
 # get the name of the branch we are on
2 2
 function git_prompt_info() {
3
-  ref=$(git symbolic-ref HEAD 2> /dev/null) || return
4
-  branch=${ref#refs/heads/}
5
-
6 3
   if [[ -d .git ]]; then
4
+    ref=$(git symbolic-ref HEAD 2> /dev/null) || return
5
+    branch=${ref#refs/heads/}
7 6
     CURRENT_BRANCH="%{$fg[red]%}git:(%{$fg[green]${branch}%{$fg[red])"
8 7
   else
9 8
     CURRENT_BRANCH=''