Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: small nit about zsh vcs_info module
- X-seq: zsh-workers 28089
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: Michel Lespinasse <walken@xxxxxxxxxx>
- Subject: Re: small nit about zsh vcs_info module
- Date: Sun, 18 Jul 2010 22:44:43 +0200
- Cc: zsh-workers@xxxxxxx
- In-reply-to: <20100718121846.GA15276@xxxxxxxxxx> (Michel Lespinasse's message of "Sun, 18 Jul 2010 05:18:46 -0700")
- 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: <20100718121846.GA15276@xxxxxxxxxx>
[..moved to -workers..]
Michel Lespinasse wrote:
> I wanted to report a small nit I have about it. Right after creating a
> new git repository with 'git init', vcs_info reports that there are staged
> files in it. This is because .git/HEAD points to refs/heads/master,
> which does not exist anymore, so git diff-index return code is 128.
[...]
> + ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2>/dev/null
> + [[ $? -eq 1 ]] && gitstaged=1
[...]
> Hope this helps. Thanks for writing the vcs_info module !
I just had a look at the source code of git's `diff-index' command. I'm
wondering: You are redirecting stderr, too. What error message did you
get?
Other than that there, seem to be legitimate return values besides `1'
and `0' with diff-index. I'm not sure if anything other than those two
apply for what we're using diff-index for, but I'd like to be safe.
How about this?
${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2>/dev/null
(( $? && $? <= 127 )) && gitstaged=1
or maybe even (( $? && $? != 128 ))
Regards, Frank
Messages sorted by:
Reverse Date,
Date,
Thread,
Author