summaryrefslogtreecommitdiff
path: root/pager.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2014-01-07 02:14:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-01-07 17:23:41 (GMT)
commite54c1f2d2533c5406abeb8e3e0cf78c68ca9c21e (patch)
treebbe2d918a0c6247be6df19d4ebd0a520f49e51f3 /pager.c
parentc90d3dbe7db37f298e7ce858cfc4c494113f8945 (diff)
downloadgit-e54c1f2d2533c5406abeb8e3e0cf78c68ca9c21e.zip
git-e54c1f2d2533c5406abeb8e3e0cf78c68ca9c21e.tar.gz
git-e54c1f2d2533c5406abeb8e3e0cf78c68ca9c21e.tar.bz2
pager: set LV=-c alongside LESS=FRSX
On systems with lv configured as the preferred pager (i.e., DEFAULT_PAGER=lv at build time, or PAGER=lv exported in the environment) git commands that use color show control codes instead of color in the pager: $ git diff ^[[1mdiff --git a/.mailfilter b/.mailfilter^[[m ^[[1mindex aa4f0b2..17e113e 100644^[[m ^[[1m--- a/.mailfilter^[[m ^[[1m+++ b/.mailfilter^[[m ^[[36m@@ -1,11 +1,58 @@^[[m "less" avoids this problem because git uses the LESS environment variable to pass the -R option ('output ANSI color escapes in raw form') by default. Use the LV environment variable to pass 'lv' the -c option ('allow ANSI escape sequences for text decoration / color') to fix it for lv, too. Noticed when the default value for color.ui flipped to 'auto' in v1.8.4-rc0~36^2~1 (2013-06-10). Reported-by: Olaf Meeuwissen <olaf.meeuwissen@avasys.jp> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pager.c')
-rw-r--r--pager.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/pager.c b/pager.c
index fa19765..c56a890 100644
--- a/pager.c
+++ b/pager.c
@@ -80,8 +80,15 @@ void setup_pager(void)
pager_process.use_shell = 1;
pager_process.argv = pager_argv;
pager_process.in = -1;
- if (!getenv("LESS")) {
- static const char *env[] = { "LESS=FRSX", NULL };
+ if (!getenv("LESS") || !getenv("LV")) {
+ static const char *env[3];
+ int i = 0;
+
+ if (!getenv("LESS"))
+ env[i++] = "LESS=FRSX";
+ if (!getenv("LV"))
+ env[i++] = "LV=-c";
+ env[i] = NULL;
pager_process.env = env;
}
if (start_command(&pager_process))