aboutsummaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-07-31 02:53:46 -0700
committerJunio C Hamano <junkio@cox.net>2006-07-31 15:32:23 -0700
commit9590b041ea464c46d5a6811df5bce83c5dd4d457 (patch)
tree7c1f434b8bcd6a62bdb3d934bfe96ee8e521edd6 /git.c
parent3e04228b0c4bbb4b5cd46db9a714dfe699fa4cb8 (diff)
downloadgit-9590b041ea464c46d5a6811df5bce83c5dd4d457.tar.gz
git-9590b041ea464c46d5a6811df5bce83c5dd4d457.tar.xz
Builtins: control the use of pager from the command table.
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>
Diffstat (limited to 'git.c')
-rw-r--r--git.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/git.c b/git.c
index 7321d6c3f..d031eb9a1 100644
--- a/git.c
+++ b/git.c
@@ -211,6 +211,7 @@ 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)
{
@@ -218,13 +219,13 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
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 },
@@ -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");