From 016b5ec7dbaab591a044e96e9dcce99a0aaeb542 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Mon, 1 Jun 2015 13:09:15 +0300 Subject: [PATCH] Use slightly faster git dirty check for untracked files --- pure.zsh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pure.zsh b/pure.zsh index 222eb67..6976a88 100644 --- a/pure.zsh +++ b/pure.zsh @@ -145,13 +145,17 @@ prompt_pure_precmd() { # fastest possible way to check if repo is dirty prompt_pure_async_git_dirty() { local untracked_dirty=$1; shift - local umode="-unormal" - [[ "$untracked_dirty" == "0" ]] && umode="-uno" # use cd -q to avoid side effects of changing directory, e.g. chpwd hooks cd -q "$*" - command test -n "$(git status --porcelain --ignore-submodules ${umode})" &>/dev/null - (($? == 0)) && echo "*" + + if [[ "$untracked_dirty" == "0" ]]; then + command git diff --no-ext-diff --quiet --exit-code + else + test -z "$(command git status --porcelain --ignore-submodules -unormal)" + fi + + (( $? )) && echo "*" } prompt_pure_async_git_fetch() {