Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] vcs_info: examples: use sed's q1 with +vi-git-untracked



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