Skip to content

Commit aa086eb

Browse files
matledJunio C Hamano
authored andcommitted
pager: config variable pager.color
enable/disable colored output when the pager is in use Signed-off-by: Matthias Lederhofer <matled@gmx.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 9590b04 commit aa086eb

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

Documentation/config.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ apply.whitespace::
116116
Tells `git-apply` how to handle whitespaces, in the same way
117117
as the '--whitespace' option. See gitlink:git-apply[1].
118118

119+
pager.color::
120+
A boolean to enable/disable colored output when the pager is in
121+
use (default is true).
122+
119123
diff.color::
120124
When true (or `always`), always use colors in patch.
121125
When false (or `never`), never. When set to `auto`, use

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ extern int receive_keep_pack(int fd[2], const char *me, int quiet, int);
386386
/* pager.c */
387387
extern void setup_pager(void);
388388
extern int pager_in_use;
389+
extern int pager_use_color;
389390

390391
/* base85 */
391392
int decode_85(char *dst, char *line, int linelen);

config.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@ int git_default_config(const char *var, const char *value)
309309
return 0;
310310
}
311311

312+
if (!strcmp(var, "pager.color")) {
313+
pager_use_color = git_config_bool(var,value);
314+
return 0;
315+
}
316+
312317
/* Add other config variables here and to Documentation/config.txt. */
313318
return 0;
314319
}

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ int git_diff_ui_config(const char *var, const char *value)
175175
diff_use_color_default = 1; /* bool */
176176
else if (!strcasecmp(value, "auto")) {
177177
diff_use_color_default = 0;
178-
if (isatty(1) || pager_in_use) {
178+
if (isatty(1) || (pager_in_use && pager_use_color)) {
179179
char *term = getenv("TERM");
180180
if (term && strcmp(term, "dumb"))
181181
diff_use_color_default = 1;

environment.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ int shared_repository = PERM_UMASK;
2323
const char *apply_default_whitespace = NULL;
2424
int zlib_compression_level = Z_DEFAULT_COMPRESSION;
2525
int pager_in_use;
26+
int pager_use_color = 1;
2627

2728
static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
2829
*git_graft_file;

0 commit comments

Comments
 (0)