agnoster: compute git repo_path only when in a git repo

this avoids needlessly invoking git twice every time we render the prompt
This commit is contained in:
Andrew Baumann 2017-07-28 11:07:24 -07:00
commit a8319ef0b3

View file

@ -94,9 +94,9 @@ prompt_git() {
PL_BRANCH_CHAR=$'\ue0a0' # 
}
local ref dirty mode repo_path
repo_path=$(git rev-parse --git-dir 2>/dev/null)
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
repo_path=$(git rev-parse --git-dir 2>/dev/null)
dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then