Skip to content

Commit 1fda91b

Browse files
torvaldsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ef45e4d commit 1fda91b

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

builtin/log.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
125125
rev->show_decorations = 1;
126126
load_ref_decorations(decoration_style);
127127
}
128+
setup_pager();
128129
}
129130

130131
/*
@@ -491,12 +492,6 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
491492
rev.use_terminator = 1;
492493
rev.always_show_header = 1;
493494

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-
500495
return cmd_log_walk(&rev);
501496
}
502497

git.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static void handle_internal_command(int argc, const char **argv)
336336
{ "index-pack", cmd_index_pack },
337337
{ "init", cmd_init_db },
338338
{ "init-db", cmd_init_db },
339-
{ "log", cmd_log, RUN_SETUP | USE_PAGER },
339+
{ "log", cmd_log, RUN_SETUP },
340340
{ "ls-files", cmd_ls_files, RUN_SETUP },
341341
{ "ls-tree", cmd_ls_tree, RUN_SETUP },
342342
{ "ls-remote", cmd_ls_remote },
@@ -380,7 +380,7 @@ static void handle_internal_command(int argc, const char **argv)
380380
{ "send-pack", cmd_send_pack, RUN_SETUP },
381381
{ "shortlog", cmd_shortlog, USE_PAGER },
382382
{ "show-branch", cmd_show_branch, RUN_SETUP },
383-
{ "show", cmd_show, RUN_SETUP | USE_PAGER },
383+
{ "show", cmd_show, RUN_SETUP },
384384
{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
385385
{ "stripspace", cmd_stripspace },
386386
{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
@@ -395,7 +395,7 @@ static void handle_internal_command(int argc, const char **argv)
395395
{ "var", cmd_var },
396396
{ "verify-tag", cmd_verify_tag, RUN_SETUP },
397397
{ "version", cmd_version },
398-
{ "whatchanged", cmd_whatchanged, RUN_SETUP | USE_PAGER },
398+
{ "whatchanged", cmd_whatchanged, RUN_SETUP },
399399
{ "write-tree", cmd_write_tree, RUN_SETUP },
400400
{ "verify-pack", cmd_verify_pack },
401401
{ "show-ref", cmd_show_ref, RUN_SETUP },

0 commit comments

Comments
 (0)