git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git diff/log --check exitcode and PAGER environment variable
@ 2008-08-08  9:39 "Peter Valdemar Mørch (Lists)"
  2008-08-08  9:44 ` Junio C Hamano
  0 siblings, 1 reply; 18+ messages in thread
From: "Peter Valdemar Mørch (Lists)" @ 2008-08-08  9:39 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2008-08-11  6:47 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-08  9:39 git diff/log --check exitcode and PAGER environment variable "Peter Valdemar Mørch (Lists)"
2008-08-08  9:44 ` 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

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).