Skip to content

Commit a3d023d

Browse files
committed
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 <[email protected]> Signed-off-by: Ben Walton <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8f4b576 commit a3d023d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ all::
201201
#
202202
# Define NO_REGEX if you have no or inferior regex support in your C library.
203203
#
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+
#
204208
# Define DEFAULT_EDITOR to a sensible editor command (defaults to "vi") if you
205209
# want to use something different. The value will be interpreted by the shell
206210
# if necessary when it is used. Examples:
@@ -1380,6 +1384,13 @@ DEFAULT_EDITOR_CQ_SQ = $(subst ','\'',$(DEFAULT_EDITOR_CQ))
13801384
BASIC_CFLAGS += -DDEFAULT_EDITOR='$(DEFAULT_EDITOR_CQ_SQ)'
13811385
endif
13821386

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+
13831394
ALL_CFLAGS += $(BASIC_CFLAGS)
13841395
ALL_LDFLAGS += $(BASIC_LDFLAGS)
13851396

pager.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#include "run-command.h"
33
#include "sigchain.h"
44

5+
#ifndef DEFAULT_PAGER
6+
#define DEFAULT_PAGER "less"
7+
#endif
8+
59
/*
610
* This is split up from the rest of git so that we can do
711
* something different on Windows.
@@ -60,7 +64,7 @@ const char *git_pager(void)
6064
if (!pager)
6165
pager = getenv("PAGER");
6266
if (!pager)
63-
pager = "less";
67+
pager = DEFAULT_PAGER;
6468
else if (!*pager || !strcmp(pager, "cat"))
6569
pager = NULL;
6670

0 commit comments

Comments
 (0)