Skip to content

Commit

Permalink
Builtins: control the use of pager from the command table.
Browse files Browse the repository at this point in the history
This moves the built-in "always-use-pager" logic for log family
to the command dispatch table of git wrapper.  This makes it
easier to change the default use of pager, and has an added
benefit that we fork and exec the pager early before packs are
mmapped.

Pointed out by Juergen Ruehle <j.ruehle@bmiag.de>.

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Jul 31, 2006
1 parent 3e04228 commit 9590b04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ static int cmd_log_walk(struct rev_info *rev)
struct commit *commit;

prepare_revision_walk(rev);
setup_pager();
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
Expand Down
13 changes: 8 additions & 5 deletions git.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,21 @@ static int handle_alias(int *argcp, const char ***argv)
const char git_version_string[] = GIT_VERSION;

#define NEEDS_PREFIX 1
#define USE_PAGER 2

static void handle_internal_command(int argc, const char **argv, char **envp)
{
const char *cmd = argv[0];
static struct cmd_struct {
const char *cmd;
int (*fn)(int, const char **, const char *);
int prefix;
int option;
} commands[] = {
{ "version", cmd_version },
{ "help", cmd_help },
{ "log", cmd_log, NEEDS_PREFIX },
{ "whatchanged", cmd_whatchanged, NEEDS_PREFIX },
{ "show", cmd_show, NEEDS_PREFIX },
{ "log", cmd_log, NEEDS_PREFIX | USE_PAGER },
{ "whatchanged", cmd_whatchanged, NEEDS_PREFIX | USE_PAGER },
{ "show", cmd_show, NEEDS_PREFIX | USE_PAGER },
{ "push", cmd_push },
{ "format-patch", cmd_format_patch, NEEDS_PREFIX },
{ "count-objects", cmd_count_objects },
Expand Down Expand Up @@ -275,8 +276,10 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
continue;

prefix = NULL;
if (p->prefix)
if (p->option & NEEDS_PREFIX)
prefix = setup_git_directory();
if (p->option & USE_PAGER)
setup_pager();
if (getenv("GIT_TRACE")) {
int i;
fprintf(stderr, "trace: built-in: git");
Expand Down

0 comments on commit 9590b04

Please sign in to comment.