Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: small nit about zsh vcs_info module
- X-seq: zsh-workers 28090
- From: Michel Lespinasse <walken@xxxxxxxxxx>
- To: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: small nit about zsh vcs_info module
- Date: Sun, 18 Jul 2010 15:43:26 -0700
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1279493019; bh=YVk7j/jnsPjwmFvS2q/Zo50jufU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=E48o46ksEpzu0VzQ1Hj7iy6SR+7/NtpbQHc22P2Ft4WlM8V3e1W92ZP2hWkuuvGgT lotHpX5lAjVOYivQKFSDg==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=date:from:to:cc:subject:message-id:references: mime-version:content-type:content-disposition:in-reply-to:user-agent:x-system-of-record; b=g47OyyJrR19JlKRdHvfu3j/JxkOHhZRrPyWENTH5XJj1rXG1tHG1trC0qoCyrlAlp y1y6+BrqbbQDa7dNvvMzw==
- In-reply-to: <87oce4v7t0.fsf@xxxxxxxxxxxxxxxxxxxxxx>
- 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> <87oce4v7t0.fsf@xxxxxxxxxxxxxxxxxxxxxx>
On Sun, Jul 18, 2010 at 10:44:43PM +0200, Frank Terbeck wrote:
> [..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?
I was getting:
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
To reproduce, just run 'git init' in an empty directory then run
'git diff-index HEAD' or any variant of it.
> 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.
I did not realize that - the doc for git diff-index --exit-code did not
mention it. However, it's still better being safe than sorry :)
> How about this?
> ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2>/dev/null
> (( $? && $? <= 127 )) && gitstaged=1
>
> or maybe even (( $? && $? != 128 ))
(( $? && $? != 128 )) looks good & works fine for me.
--
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author