【问题标题】:What does git log --exit-code mean?git log --exit-code 是什么意思?
【发布时间】:2015-09-29 21:21:14
【问题描述】:

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

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

【问题讨论】:

  • 有一些有限的方式可以使 --exit-code 与log(而不是diff)一起使用,因为 log 可以像 diff 一样,支持像 --ignore-whitesape 这样的标志, --ignore-space-at-eol 等。所以即使没有 -p(打印补丁)git log -w -n 1 HEAD --exit-code 也会给出不同的结果,具体取决于补丁中是否存在非空白更改。

标签: git command-line-interface


【解决方案1】:

TL;博士

我想知道--exit-code 是什么意思 [...]

--exit-code 是一个diff-*1 选项,如果有更改,则使用1 退出Git 命令,否则使用0

[...] 但我在任何地方都找不到。

您可以在 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 选项不是,正如 Git-project repository 中的以下 commit message 所暗示的那样:

文档:不要在 git-log(1) 中提及 --quiet--exit-code

这些是diff-options,但实际上没有意义 在log 的上下文中。

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

【讨论】:

  • --exit-codelog 的上下文中确实有意义,尤其是在使用--grep 时。
【解决方案2】:

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

"使程序退出,代码类似于diff(1),即有差异则退出,0表示无差异。"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-14
    • 1970-01-01
    • 2016-12-02
    • 2017-12-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多