From: Daniel Hahler <genml+zsh-workers@thequod.de>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: Re: [PATCH] vcs_info: examples: use sed's q1 with +vi-git-untracked
Date: Mon, 27 Apr 2015 05:01:47 +0200 [thread overview]
Message-ID: <553DA69B.3050706@thequod.de> (raw)
In-Reply-To: <19434.1427989332@thecus.kiddle.eu>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 02.04.2015 17:42, Oliver Kiddle wrote:
> Daniel Hahler wrote:
>>
>> This short-circuits the git command if there is any match.
>>
>> Especially with `git ls-files` this is faster, although the additional
>
> Unfortunately, the exit code after q is a GNU sed extension so this now
> breaks on non-Linux systems.
>
> Portable alternatives that come to mind include: piping to head -1 and using
> $pipestatus, using sed q and testing for output, using awk. There's
> probably something better than those, however.
Using "grep -q" would probably solve it already for the "git status"
case (which uses grep already), and "| grep -q ." could be used for
"git ls-files".
I've also found that "git status" can be noticably slower than "ls-files",
so I'd suggest to use this instead.
Additionally, the hook appears to be only called if there's a gitdir anyway,
so the check ("git rev-parse --is-inside-work-tree") could be removed.
I am using this currently:
# vcs_info: git: Show marker (✗) if there are untracked files in repository.
# (via %c).
function +vi-git-untracked() {
[[ $1 == 0 ]] || return # do this only once for vcs_info_msg_0_.
local gitdir=${vcs_comm[gitdir]}
if command git --git-dir $gitdir ls-files --other --directory --exclude-standard | command grep -q .; then
hook_com[staged]+='✗ '
fi
}
What do you think?
Should I update the patch?
Regards,
Daniel.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
iD8DBQFVPaabfAK/hT/mPgARAgfCAJ40olRYsAJfMQtoLcfjkQow2XwEJACgg38X
itDWMXo5xDpm5sykhCezxYY=
=YrSU
-----END PGP SIGNATURE-----
prev parent reply other threads:[~2015-04-27 3:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-02 13:21 Daniel Hahler
2015-04-02 15:42 ` Oliver Kiddle
2015-04-27 3:01 ` Daniel Hahler [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=553DA69B.3050706@thequod.de \
--to=genml+zsh-workers@thequod.de \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).