Skip to content

Commit

Permalink
diff: don't run pager if user asked for a diff style exit code
Browse files Browse the repository at this point in the history
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: Rene Scharfe <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
René Scharfe authored and gitster committed Aug 13, 2007
1 parent 4b37666 commit 89d07f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion git.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down

0 comments on commit 89d07f7

Please sign in to comment.