Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] vcs_info: examples: use sed's q1 with +vi-git-untracked
- X-seq: zsh-workers 34834
- From: Daniel Hahler <genml+zsh-workers@xxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] vcs_info: examples: use sed's q1 with +vi-git-untracked
- Date: Thu, 2 Apr 2015 15:21:38 +0200
- 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=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
From: Daniel Hahler <git@xxxxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author