@matheusbsbs / matheus-bagliano / commits / a3d023d0a3
Fork 0

Provide a build time default-pager setting

Provide a DEFAULT_PAGER knob so packagers can set the fallback pager to something appropriate during the build. Examples: On (old) solaris systems, /usr/bin/less (typically the first less found) doesn't understand the default arguments (FXRS), which forces users to alter their environment (PATH, GIT_PAGER, LESS, etc) or have a local or global gitconfig before paging works as expected. On Debian systems, by policy packages must fall back to the 'pager' command, so that changing the target of the /usr/bin/pager symlink changes the default pager for all packages at once. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Oct 30, 2009 at 20:45 UTC a3d023d0a3783612053f2149e784b43befceccad
2 files changed +16 -1
Makefile
+11
@@ -201,6 +201,10 @@ all::
201 #
202 # Define NO_REGEX if you have no or inferior regex support in your C library.
203 #
204 +# Define DEFAULT_PAGER to a sensible pager command (defaults to "less") if
205 +# you want to use something different. The value will be interpreted by the
206 +# shell at runtime when it is used.
207 +#
208 # Define DEFAULT_EDITOR to a sensible editor command (defaults to "vi") if you
209 # want to use something different. The value will be interpreted by the shell
210 # if necessary when it is used. Examples:
@@ -1380,6 +1384,13 @@ DEFAULT_EDITOR_CQ_SQ = $(subst ','\'',$(DEFAULT_EDITOR_CQ))
1384 BASIC_CFLAGS += -DDEFAULT_EDITOR='$(DEFAULT_EDITOR_CQ_SQ)'
1385 endif
1386
1387 +ifdef DEFAULT_PAGER
1388 +DEFAULT_PAGER_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_PAGER)))"
1389 +DEFAULT_PAGER_CQ_SQ = $(subst ','\'',$(DEFAULT_PAGER_CQ))
1390 +
1391 +BASIC_CFLAGS += -DDEFAULT_PAGER='$(DEFAULT_PAGER_CQ_SQ)'
1392 +endif
1393 +
1394 ALL_CFLAGS += $(BASIC_CFLAGS)
1395 ALL_LDFLAGS += $(BASIC_LDFLAGS)
1396
pager.c
+5 -1
@@ -2,6 +2,10 @@
2 #include "run-command.h"
3 #include "sigchain.h"
4
5 +#ifndef DEFAULT_PAGER
6 +#define DEFAULT_PAGER "less"
7 +#endif
8 +
9 /*
10 * This is split up from the rest of git so that we can do
11 * something different on Windows.
@@ -60,7 +64,7 @@ const char *git_pager(void)
64 if (!pager)
65 pager = getenv("PAGER");
66 if (!pager)
63 - pager = "less";
67 + pager = DEFAULT_PAGER;
68 else if (!*pager || !strcmp(pager, "cat"))
69 pager = NULL;
70