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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html