From: "\"Peter Valdemar Mørch (Lists)\"" <4ux6as402@sneakemail.com>
To: git@vger.kernel.org
Subject: git diff/log --check exitcode and PAGER environment variable
Date: Fri, 08 Aug 2008 11:39:39 +0200 [thread overview]
Message-ID: <489C145B.5090400@sneakemail.com> (raw)
Using my default PAGER=less, git log --check exits with exit code 0,
contrary to documentation.
There is this old thread:
"[PATCH 1/5] "diff --check" should affect exit status"
http://thread.gmane.org/gmane.comp.version-control.git/68145/focus=68148
which seemed not to reach a conclusion.
For git log, I still have not been able to make it exit with anything
other than 0 - contrary to documentation.
May I propose a change to either documentation or behavior of "git diff
--check". The current one has:
--check::
Warn if changes introduce trailing whitespace
or an indent that uses a space before a tab. Exits with
non-zero status if problems are found. Not compatible with
--exit-code.
This, clearly, is not correct:
$ PAGER=less git diff --check
(my default PAGER)
or
$ unset PAGER ; git diff --check
always exits with exit code 0. But
$ git --no-pager diff --check
or
$ PAGER=cat git diff --check
or
$ PAGER= git diff --check
exits with exit code 2 on error
(curiously PAGER= and unset PAGER give different results)
But the --exit-code overrides any of that:
$ git --no-pager diff --check --exit-code
exits with exit code 3 on error (with or without the --no-pager).
I'm not sure about a good rephrasing. How about:
'... "git diff" exits with non-zero status if problems are found and run
with --exit-code.'
While this documentation string is found in diff-options.txt and
included in:
git-diff-files.txt
git-diff-index.txt
git-diff-tree.txt
git-diff.txt
git-format-patch.txt
git-log.txt
At least for the git-log cases, the behavior is not the same as for
git-diff:
$ PAGER=cat git --no-pager log HEAD~20..HEAD --check --exit-code
$ echo $?
0
Though there are several check failures (red squares in output), it
exits with 0, even when using all the tricks that work with "git diff".
Clearly here, the documentation is "even more wrong". Hence the explicit
mention of "git diff" in the help string for the --check option.
What do you think?
Peter
--
Peter Valdemar Mørch
http://www.morch.com
next reply other threads:[~2008-08-08 9:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-08 9:39 "Peter Valdemar Mørch (Lists)" [this message]
2008-08-08 9:44 ` git diff/log --check exitcode and PAGER environment variable Junio C Hamano
2008-08-08 10:04 ` "Peter Valdemar Mørch (Lists)"
2008-08-08 10:15 ` Re* " Junio C Hamano
2008-08-08 11:02 ` "Peter Valdemar Mørch (Lists)"
2008-08-08 11:23 ` Johannes Schindelin
2008-08-08 20:40 ` Junio C Hamano
2008-08-09 6:57 ` [PATCH] Teach git log --check to return an appropriate error code Peter Valdemar Mørch
2008-08-09 12:05 ` Johannes Schindelin
2008-08-09 19:29 ` Junio C Hamano
2008-08-10 17:05 ` "Peter Valdemar Mørch (Lists)"
2008-08-10 18:40 ` Junio C Hamano
2008-08-09 18:58 ` Junio C Hamano
2008-08-11 6:46 ` PATCH v2 0/2 Trying patch again Peter Valdemar Mørch
2008-08-11 6:46 ` [PATCH v2 1/2] Teach git log --check to return an appropriate exit code Peter Valdemar Mørch
2008-08-11 6:46 ` [PATCH v2 2/2] Teach git log --exit-code " Peter Valdemar Mørch
2008-08-08 13:17 ` git diff/log --check exitcode and PAGER environment variable Jeff King
2008-08-08 13:19 ` Jeff King
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=489C145B.5090400@sneakemail.com \
--to=4ux6as402@sneakemail.com \
--cc=git@vger.kernel.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.
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).