summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 44fcb49)
raw | patch | inline | side by side (parent: 44fcb49)
author | Jonathan Nieder <jrnieder@gmail.com> | |
Sat, 31 Oct 2009 01:41:27 +0000 (20:41 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 13 Nov 2009 20:20:47 +0000 (12:20 -0800) |
Expose the command found by setup_pager() for scripts to use.
Scripts can use this to avoid repeating the logic to look for a
proper pager in each command.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Scripts can use this to avoid repeating the logic to look for a
proper pager in each command.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-var.txt | patch | blob | history | |
cache.h | patch | blob | history | |
pager.c | patch | blob | history | |
var.c | patch | blob | history |
index 89e4b4fa0c7c8378cbce46ba8ef460777b3114e7..ef6aa81872eb9e67eaf8183cfd5359d97e6c772b 100644 (file)
environment variable, then `core.editor` configuration, then
`$VISUAL`, then `$EDITOR`, and then finally 'vi'.
+GIT_PAGER::
+ Text viewer for use by git commands (e.g., 'less'). The value
+ is meant to be interpreted by the shell. The order of preference
+ is the `$GIT_PAGER` environment variable, then `core.pager`
+ configuration, then `$PAGER`, and then finally 'less'.
+
Diagnostics
-----------
You don't exist. Go away!::
index 311cfe121945634fd903a0ee9178548c5408c7e1..5aaa4bac98e1ccba7426b2003f2488b7e41b346b 100644 (file)
--- a/cache.h
+++ b/cache.h
extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int);
extern const char *fmt_name(const char *name, const char *email);
extern const char *git_editor(void);
+extern const char *git_pager(void);
struct checkout {
const char *base_dir;
index 86facec7b417b26a7dbd9b3c1338149fcecd5588..0b63d99fe770153bdfcc99d23ef45befc14d45b0 100644 (file)
--- a/pager.c
+++ b/pager.c
raise(signo);
}
-void setup_pager(void)
+const char *git_pager(void)
{
- const char *pager = getenv("GIT_PAGER");
+ const char *pager;
if (!isatty(1))
- return;
+ return NULL;
+
+ pager = getenv("GIT_PAGER");
if (!pager) {
if (!pager_program)
git_config(git_default_config, NULL);
if (!pager)
pager = "less";
else if (!*pager || !strcmp(pager, "cat"))
+ pager = NULL;
+
+ return pager;
+}
+
+void setup_pager(void)
+{
+ const char *pager = git_pager();
+
+ if (!pager)
return;
spawned_pager = 1; /* means we are emitting to terminal */
index b502487e536d76d10370182427fb0f4ab8af8a7b..d9892f85ce954883427ac4f61d9de9d591c0827c 100644 (file)
--- a/var.c
+++ b/var.c
return pgm;
}
+static const char *pager(int flag)
+{
+ const char *pgm = git_pager();
+
+ if (!pgm)
+ pgm = "cat";
+ return pgm;
+}
+
struct git_var {
const char *name;
const char *(*read)(int);
{ "GIT_COMMITTER_IDENT", git_committer_info },
{ "GIT_AUTHOR_IDENT", git_author_info },
{ "GIT_EDITOR", editor },
+ { "GIT_PAGER", pager },
{ "", NULL },
};