zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] vcs_info: examples: use sed's q1 with +vi-git-untracked
@ 2015-04-02 13:21 Daniel Hahler
  2015-04-02 15:42 ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Hahler @ 2015-04-02 13:21 UTC (permalink / raw)
  To: zsh-workers

From: Daniel Hahler <git@thequod.de>

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-27  3:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-02 13:21 [PATCH] vcs_info: examples: use sed's q1 with +vi-git-untracked Daniel Hahler
2015-04-02 15:42 ` Oliver Kiddle
2015-04-27  3:01   ` Daniel Hahler

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).