git log --exit-code 是什么意思?

What does git log --exit-code mean?

git-log man page--check 选项描述为与 --exit-code 选项不兼容。我想知道这个 --exit-code 是什么意思,但我到处都找不到。我试过 man git logman git、Google 并直接在此处搜索...无济于事!

--exit-codegit log 意味着什么?

它在 git-diff docs 中提到(并且显然不打算与 git-log 一起使用):

"Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means no differences."

TL;博士

I'd like to know what this --exit-code means [...]

--exit-code 是一个 diff-*1 选项,它使 Git 命令在有更改时以 1 退出,和 0 否则。

[...] but I can't find it anywhere.

您可以在 git-diff 手册页中阅读它(它仅在 git-log 手册页中被提及)。

更多详情

--check--exit-code 都在 git-diff 手册页中进行了描述(更具体地说,在 Documentation/diff-options.txt 中):

   --check
 Warn if changes introduce whitespace errors. What are considered
 whitespace errors is controlled by core.whitespace configuration.
 By default, trailing whitespaces (including lines that solely
 consist of whitespaces) and a space character that is immediately
 followed by a tab character inside the initial indent of the line
 are considered whitespace errors. Exits with non-zero status if
 problems are found. Not compatible with --exit-code.

   --exit-code
 Make the program exit with codes similar to diff(1). That is, it
 exits with 1 if there were differences and 0 means no differences.

有些 diff-* 选项与 git-log 兼容,但不是全部。 --check 选项是,而 --exit-code 选项不是,正如以下 commit message from the Git-project repository:

所暗示的

docs: don't mention --quiet or --exit-code in git-log(1)

These are diff-options, but they don't actually make sense in the context of log.

(1) diff-* 代表 porcelain git-diff 所基于的管道命令。