From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Wincent Colaiuta <win@wincent.com>
Cc: git@vger.kernel.org
Subject: Re: --exit-code (and --quiet) broken in git-diff?
Date: Sun, 12 Aug 2007 11:40:58 +0200 [thread overview]
Message-ID: <46BED5AA.7050900@lsrfire.ath.cx> (raw)
In-Reply-To: <17875.88.10.191.55.1186873960.squirrel@secure.wincent.com>
Wincent Colaiuta schrieb:
> The git-diff man page documents an "--exit-code" option, as well as a
> "--quiet" option which automatically implies the former.
>
> In my tests on Mac OS X and Bash 3, however, "git diff" always return an
> exit code of 0, never of 1, regardless of how I use the "--quiet" and
> "--exit-code" options. I see that there are tests in t/t4017-quiet.sh for
> the lower-level git-diff-files, git-diff-index, git-diff-tree commands,
> but none for the porcelain git-diff.
>
> Is this a bug with a missing test case? Or am I using this incorrectly? In
> the example below I'm looking for differences between the working tree and
> the last commit, so I'm using "git diff HEAD", but as you can see, the
> exit code is always 0 for "git diff" and "git diff --cached" as well:
>
> $ git --version
> git version 1.5.2.4
> $ mkdir example
> $ cd example
> $ git init
> Initialized empty Git repository in .git/
> $ echo "start" > foo
> $ git add foo
> $ git commit -m "Add foo"
> Created initial commit 85954f6: Add foo
> 1 files changed, 1 insertions(+), 0 deletions(-)
> create mode 100644 foo
> $ git diff --quiet HEAD; echo $?
> 0
> $ echo "more" >> foo
> $ git diff --quiet HEAD; echo $?
> 0
> $ git add foo
> $ git diff --quiet HEAD; echo $?
> 0
> $ git diff --quiet; echo $?
> 0
> $ git diff --exit-code; echo $?
> 0
> $ git diff --cached --quiet; echo $?
> 0
git diff passes the output through your pager by default, so you see the
exit code of that instead of diff's. Set PAGER=cat or redirect the
output to /dev/null to get rid of it.
A test case for diff would be nice regardless, though. :)
René
next prev parent reply other threads:[~2007-08-12 9:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-11 23:12 --exit-code (and --quiet) broken in git-diff? Wincent Colaiuta
2007-08-12 9:40 ` René Scharfe [this message]
2007-08-12 11:24 ` Wincent Colaiuta
2007-08-12 11:31 ` David Kastrup
2007-08-12 13:02 ` Steven Grimm
2007-08-12 13:29 ` David Kastrup
2007-08-12 16:57 ` Wincent Colaiuta
2007-08-12 11:33 ` Steffen Prohaska
2007-08-12 17:46 ` [PATCH] diff: don't run pager if user asked for a diff style exit code René Scharfe
2007-08-13 9:57 ` Wincent Colaiuta
2007-08-13 10:23 ` David Kastrup
2007-08-13 23:42 ` Junio C Hamano
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=46BED5AA.7050900@lsrfire.ath.cx \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=git@vger.kernel.org \
--cc=win@wincent.com \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.