提交 89d07f75 编写于 作者: R René Scharfe 提交者: Junio C Hamano

diff: don't run pager if user asked for a diff style exit code

As Wincent Colaiuta found out, it's a bit unexpected for git diff to
start a pager even when the --quiet option is specified.  The problem
is that the pager hides the return code -- which is the only output
we're interested in in this case.

Push pager setup down into builtin-diff.c and don't start the pager
if --exit-code or --quiet (which implies --exit-code) was specified.
Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 4b37666c
......@@ -235,6 +235,12 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
rev.diffopt.allow_external = 1;
rev.diffopt.recursive = 1;
/* If the user asked for our exit code then don't start a
* pager or we would end up reporting its exit code instead.
*/
if (!rev.diffopt.exit_with_status)
setup_pager();
/* Do we have --cached and not have a pending object, then
* default to HEAD by hand. Eek.
*/
......
......@@ -325,7 +325,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "config", cmd_config },
{ "count-objects", cmd_count_objects, RUN_SETUP },
{ "describe", cmd_describe, RUN_SETUP },
{ "diff", cmd_diff, USE_PAGER },
{ "diff", cmd_diff },
{ "diff-files", cmd_diff_files },
{ "diff-index", cmd_diff_index, RUN_SETUP },
{ "diff-tree", cmd_diff_tree, RUN_SETUP },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册