From: Matthias Lederhofer <matled@gmx.net>
To: git@vger.kernel.org
Subject: [PATCH] pager: config variable pager.program
Date: Sat, 29 Jul 2006 23:28:13 +0200 [thread overview]
Message-ID: <E1G6wM1-00040z-Bu@moooo.ath.cx> (raw)
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
I'd like to use another pager (or other options) with git than the
normal pager. Normally I would not want the -R option with less but
for git less should show colors.
---
Documentation/config.txt | 5 +++++
| 16 +++++++++++++++-
2 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 465eb13..96429b6 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -116,6 +116,11 @@ apply.whitespace::
Tells `git-apply` how to handle whitespaces, in the same way
as the '--whitespace' option. See gitlink:git-apply[1].
+pager.program::
+ Use this program as pager. git will try this configuration
+ variable first, then the 'PAGER' environment variable and
+ "less" as fallback.
+
diff.color::
When true (or `always`), always use colors in patch.
When false (or `never`), never. When set to `auto`, use
--git a/pager.c b/pager.c
index 280f57f..3f753f6 100644
--- a/pager.c
+++ b/pager.c
@@ -5,6 +5,18 @@ #include "cache.h"
* something different on Windows, for example.
*/
+static const char *pager = NULL;
+
+static int git_pager_config(const char *var, const char *value)
+{
+ if (!strcmp(var, "pager.program")) {
+ if (value)
+ pager = strdup(value);
+ return 0;
+ }
+ return 0;
+}
+
static void run_pager(const char *pager)
{
execlp(pager, pager, NULL);
@@ -15,10 +27,12 @@ void setup_pager(void)
{
pid_t pid;
int fd[2];
- const char *pager = getenv("PAGER");
if (!isatty(1))
return;
+ git_config(git_pager_config);
+ if (!pager)
+ pager = getenv("PAGER");
if (!pager)
pager = "less";
else if (!*pager || !strcmp(pager, "cat"))
--
1.4.2.rc2.g688a
next reply other threads:[~2006-07-29 21:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-29 21:28 Matthias Lederhofer [this message]
2006-07-31 0:43 ` [PATCH] pager: config variable pager.program Junio C Hamano
2006-07-31 12:14 ` Matthias Lederhofer
2006-07-31 12:56 ` Johannes Schindelin
2006-07-31 13:27 ` [PATCH] pager: environment variable GIT_PAGER to override PAGER Matthias Lederhofer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1G6wM1-00040z-Bu@moooo.ath.cx \
--to=matled@gmx.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox