summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2010-11-17 12:04:12 -0500
committerJunio C Hamano <gitster@pobox.com>2010-11-17 11:37:06 -0800
commit9bad7233699e1fcf58e75f1e163499ec24680826 (patch)
treed6e85cf6685d7a3d88c45702a9aead6c6f99f66e /git.c
parentb2be2f6aeaa8f4af602679e5571d2e916a259d91 (diff)
downloadgit-9bad7233699e1fcf58e75f1e163499ec24680826.tar.gz
allow command-specific pagers in pager.<cmd>
A user may want different pager settings or even a different pager for various subcommands (e.g., because they use different less settings for "log" vs "diff", or because they have a pager that interprets only log output but not other commands). This patch extends the pager.<cmd> syntax to support not only boolean to-page-or-not-to-page, but also to specify a pager just for a specific command. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git.c')
-rw-r--r--git.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/git.c b/git.c
index 0409ac9fd3..81221cff46 100644
--- a/git.c
+++ b/git.c
@@ -19,14 +19,22 @@ static struct startup_info git_startup_info;
static int use_pager = -1;
struct pager_config {
const char *cmd;
- int val;
+ int want;
+ char *value;
};
static int pager_command_config(const char *var, const char *value, void *data)
{
struct pager_config *c = data;
- if (!prefixcmp(var, "pager.") && !strcmp(var + 6, c->cmd))
- c->val = git_config_bool(var, value);
+ if (!prefixcmp(var, "pager.") && !strcmp(var + 6, c->cmd)) {
+ int b = git_config_maybe_bool(var, value);
+ if (b >= 0)
+ c->want = b;
+ else {
+ c->want = 1;
+ c->value = xstrdup(value);
+ }
+ }
return 0;
}
@@ -35,9 +43,12 @@ int check_pager_config(const char *cmd)
{
struct pager_config c;
c.cmd = cmd;
- c.val = -1;
+ c.want = -1;
+ c.value = NULL;
git_config(pager_command_config, &c);
- return c.val;
+ if (c.value)
+ pager_program = c.value;
+ return c.want;
}
static void commit_pager_choice(void) {