From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17518 invoked by alias); 2 Apr 2015 13:28:05 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34834 Received: (qmail 25554 invoked from network); 2 Apr 2015 13:27:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= x-mailer:message-id:date:date:subject:subject:from:from:received :received:received; s=postfix2; t=1427980905; bh=B0yPnbeAfUSMGtM ru7Q4TKbBEcPQxx6qP2V7brnVMhY=; b=nxRqO9+3b4Onu1Qqfw3ecsAMkW+abjr nOc80ytuqFvi0VUNeweAZwemRpS14jYlstb8RJM7/nT+SaJjoZCV28kWyiN/9vI/ fMlD5RTmxWY/xxG6Jziag/StLHkr7/mSML6V7Ffic9QJmdnBo+OTPRJxuRx4MoLi 31n362rP/rjY= From: Daniel Hahler To: zsh-workers@zsh.org Subject: [PATCH] vcs_info: examples: use sed's q1 with +vi-git-untracked Date: Thu, 2 Apr 2015 15:21:38 +0200 Message-Id: <1427980898-13096-1-git-send-email-genml+zsh-workers@thequod.de> X-Mailer: git-send-email 2.3.3.220.g9ab698f.dirty From: Daniel Hahler This short-circuits the git command if there is any match. Especially with `git ls-files` this is faster, although the additional `--directory` (to only display directories, if they are untracked completely, instead of all files in there) might make up for most of it. --- Misc/vcs_info-examples | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples index 766eb82..5337792 100644 --- a/Misc/vcs_info-examples +++ b/Misc/vcs_info-examples @@ -160,11 +160,11 @@ zstyle ':vcs_info:git*+set-message:*' hooks git-untracked +vi-git-untracked(){ if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \ - git status --porcelain | grep '??' &> /dev/null ; then + ! git status --porcelain | sed -n '/^??/q1' ; then # This will show the marker if there are any untracked files in repo. # If instead you want to show the marker only if there are untracked # files in $PWD, use: - #[[ -n $(git ls-files --others --exclude-standard) ]] ; then + # ! git ls-files --others --directory --exclude-standard | sed -n q1; then hook_com[staged]+='T' fi } -- 2.3.3.220.g9ab698f.dirty