@matheusbsbs / matheus-bagliano / commits / 1fda91b511
Fork 0

Fix 'git log' early pager startup error case

We start the pager too early for several git commands, which results in the errors sometimes going to the pager rather than show up as errors. This is often hidden by the fact that we pass in '-X' to less by default, which causes 'less' to exit for small output, but if you do export LESS=-S you can then clearly see the problem by doing git log --prretty which shows the error message ("fatal: unrecognized argument: --prretty") being sent to the pager. This happens for pretty much all git commands that use USE_PAGER, and then check arguments separately. But "git diff" does it too early too (even though it does an explicit setup_pager() call) This only fixes it for the trivial "git log" family case. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Linus Torvalds committed Aug 24, 2010 at 10:33 UTC 1fda91b511c76eb233f99877c60d1c5f7801f647
2 files changed +4 -9
builtin/log.c
+1 -6
@@ -125,6 +125,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
125 rev->show_decorations = 1;
126 load_ref_decorations(decoration_style);
127 }
128 + setup_pager();
129 }
130
131 /*
@@ -491,12 +492,6 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
492 rev.use_terminator = 1;
493 rev.always_show_header = 1;
494
494 - /*
495 - * We get called through "git reflog", so unlike the other log
496 - * routines, we need to set up our pager manually..
497 - */
498 - setup_pager();
499 -
495 return cmd_log_walk(&rev);
496 }
497
git.c
+3 -3
@@ -336,7 +336,7 @@ static void handle_internal_command(int argc, const char **argv)
336 { "index-pack", cmd_index_pack },
337 { "init", cmd_init_db },
338 { "init-db", cmd_init_db },
339 - { "log", cmd_log, RUN_SETUP | USE_PAGER },
339 + { "log", cmd_log, RUN_SETUP },
340 { "ls-files", cmd_ls_files, RUN_SETUP },
341 { "ls-tree", cmd_ls_tree, RUN_SETUP },
342 { "ls-remote", cmd_ls_remote },
@@ -380,7 +380,7 @@ static void handle_internal_command(int argc, const char **argv)
380 { "send-pack", cmd_send_pack, RUN_SETUP },
381 { "shortlog", cmd_shortlog, USE_PAGER },
382 { "show-branch", cmd_show_branch, RUN_SETUP },
383 - { "show", cmd_show, RUN_SETUP | USE_PAGER },
383 + { "show", cmd_show, RUN_SETUP },
384 { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
385 { "stripspace", cmd_stripspace },
386 { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
@@ -395,7 +395,7 @@ static void handle_internal_command(int argc, const char **argv)
395 { "var", cmd_var },
396 { "verify-tag", cmd_verify_tag, RUN_SETUP },
397 { "version", cmd_version },
398 - { "whatchanged", cmd_whatchanged, RUN_SETUP | USE_PAGER },
398 + { "whatchanged", cmd_whatchanged, RUN_SETUP },
399 { "write-tree", cmd_write_tree, RUN_SETUP },
400 { "verify-pack", cmd_verify_pack },
401 { "show-ref", cmd_show_ref, RUN_SETUP },