Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] vcs_info: examples: use sed's q1 with +vi-git-untracked
- X-seq: zsh-workers 34968
- From: Daniel Hahler <genml+zsh-workers@xxxxxxxxxx>
- To: Zsh Hackers' List <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] vcs_info: examples: use sed's q1 with +vi-git-untracked
- Date: Mon, 27 Apr 2015 05:01:47 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= content-transfer-encoding:content-type:content-type:in-reply-to :references:subject:subject:mime-version:user-agent:from:from :date:date:message-id:received:received; s=postfix2; t= 1430103708; bh=W53y8y3dZbNDaG5EnCAGUB7V0u8dbopsdVWvmLPDDZE=; b=h wKt/DF6KxQafTvzvCfn/Kl7XGCJ9R4ON6zDTAomFXlEW1rFVVwJsW3QnsB2fKicC +SMjTJyCcSr+q2Je0USSH5AE//4MmOHioNH0TV4ypACFIhluX+Vspqmd8I8BJZTk eLNNeU0XAPBin4iDCf3qiYUrSsRWDpWmC90ceYLblQ=
- In-reply-to: <19434.1427989332@thecus.kiddle.eu>
- 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
- References: <1427980898-13096-1-git-send-email-genml+zsh-workers@thequod.de> <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-----
Messages sorted by:
Reverse Date,
Date,
Thread,
Author