]> asedeno.scripts.mit.edu Git - git.git/commitdiff
pager: config variable pager.color
authorMatthias Lederhofer <matled@gmx.net>
Sat, 29 Jul 2006 22:27:43 +0000 (00:27 +0200)
committerJunio C Hamano <junkio@cox.net>
Mon, 31 Jul 2006 22:32:24 +0000 (15:32 -0700)
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>
Documentation/config.txt
cache.h
config.c
diff.c
environment.c

index 465eb13e76dca5cf4daad9d5ea773f4743452c75..e669003f72de9be376f04847faf2a125c147491e 100644 (file)
@@ -116,6 +116,10 @@ apply.whitespace::
        Tells `git-apply` how to handle whitespaces, in the same way
        as the '--whitespace' option. See gitlink:git-apply[1].
 
+pager.color::
+       A boolean to enable/disable colored output when the pager is in
+       use (default is true).
+
 diff.color::
        When true (or `always`), always use colors in patch.
        When false (or `never`), never.  When set to `auto`, use
diff --git a/cache.h b/cache.h
index c575b8a9962d4eec64e91b1b0df38e60b20df288..b8c21e07b2e714de8e4e662b31a41ff06c5e0c9a 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -386,6 +386,7 @@ extern int receive_keep_pack(int fd[2], const char *me, int quiet, int);
 /* pager.c */
 extern void setup_pager(void);
 extern int pager_in_use;
+extern int pager_use_color;
 
 /* base85 */
 int decode_85(char *dst, char *line, int linelen);
index 0ac6aebbbcbd666d5bd8201ce28e1868bd6d5a30..82b35624543a2e50d80cafab15b63df0152adbc0 100644 (file)
--- a/config.c
+++ b/config.c
@@ -309,6 +309,11 @@ int git_default_config(const char *var, const char *value)
                return 0;
        }
 
+       if (!strcmp(var, "pager.color")) {
+               pager_use_color = git_config_bool(var,value);
+               return 0;
+       }
+
        /* Add other config variables here and to Documentation/config.txt. */
        return 0;
 }
diff --git a/diff.c b/diff.c
index 6a713764831e7521958f4b280f2e1d3911fb3cea..607c357f5ad8ff07c69dec7c185d667db4e43397 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -175,7 +175,7 @@ int git_diff_ui_config(const char *var, const char *value)
                        diff_use_color_default = 1; /* bool */
                else if (!strcasecmp(value, "auto")) {
                        diff_use_color_default = 0;
-                       if (isatty(1) || pager_in_use) {
+                       if (isatty(1) || (pager_in_use && pager_use_color)) {
                                char *term = getenv("TERM");
                                if (term && strcmp(term, "dumb"))
                                        diff_use_color_default = 1;
index 42f39d657ef0056667bb8814622e0dde2733e373..87162b257254434be356b1a579967d51adff1e5f 100644 (file)
@@ -23,6 +23,7 @@ int shared_repository = PERM_UMASK;
 const char *apply_default_whitespace = NULL;
 int zlib_compression_level = Z_DEFAULT_COMPRESSION;
 int pager_in_use;
+int pager_use_color = 1;
 
 static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
        *git_graft_file;