@matheusbsbs / matheus-bagliano / commits / 89d07f750a
Fork 0

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: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Aug 12, 2007 at 19:46 UTC 89d07f750a3f878c42b3de96ee93dc571b42b230
2 files changed +7 -1
builtin-diff.c
+6
@@ -235,6 +235,12 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
235 rev.diffopt.allow_external = 1;
236 rev.diffopt.recursive = 1;
237
238 + /* If the user asked for our exit code then don't start a
239 + * pager or we would end up reporting its exit code instead.
240 + */
241 + if (!rev.diffopt.exit_with_status)
242 + setup_pager();
243 +
244 /* Do we have --cached and not have a pending object, then
245 * default to HEAD by hand. Eek.
246 */
git.c
+1 -1
@@ -325,7 +325,7 @@ static void handle_internal_command(int argc, const char **argv)
325 { "config", cmd_config },
326 { "count-objects", cmd_count_objects, RUN_SETUP },
327 { "describe", cmd_describe, RUN_SETUP },
328 - { "diff", cmd_diff, USE_PAGER },
328 + { "diff", cmd_diff },
329 { "diff-files", cmd_diff_files },
330 { "diff-index", cmd_diff_index, RUN_SETUP },
331 { "diff-tree", cmd_diff_tree, RUN_SETUP },