From: Matthias Lederhofer <matled@gmx.net>
To: git@vger.kernel.org
Subject: [PATCH] pager: config variable pager.color
Date: Sun, 30 Jul 2006 00:27:43 +0200 [thread overview]
Message-ID: <E1G6xHb-0008Rw-G2@moooo.ath.cx> (raw)
enable/disable colored output when the pager is in use
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
setup_pager has to be called before git_diff_ui_config because the
latter uses pager_use_color initialized by setup_pager.
---
Documentation/config.txt | 4 ++++
builtin-log.c | 4 +++-
cache.h | 1 +
diff.c | 2 +-
environment.c | 1 +
| 4 ++++
6 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 96429b6..5e243a8 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -121,6 +121,10 @@ pager.program::
variable first, then the 'PAGER' environment variable and
"less" as fallback.
+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/builtin-log.c b/builtin-log.c
index 82c69d1..7fdefec 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -34,7 +34,6 @@ static int cmd_log_walk(struct rev_info
struct commit *commit;
prepare_revision_walk(rev);
- setup_pager();
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
@@ -49,6 +48,7 @@ int cmd_whatchanged(int argc, const char
{
struct rev_info rev;
+ setup_pager();
git_config(git_diff_ui_config);
init_revisions(&rev, prefix);
rev.diff = 1;
@@ -64,6 +64,7 @@ int cmd_show(int argc, const char **argv
{
struct rev_info rev;
+ setup_pager();
git_config(git_diff_ui_config);
init_revisions(&rev, prefix);
rev.diff = 1;
@@ -81,6 +82,7 @@ int cmd_log(int argc, const char **argv,
{
struct rev_info rev;
+ setup_pager();
git_config(git_diff_ui_config);
init_revisions(&rev, prefix);
rev.always_show_header = 1;
diff --git a/cache.h b/cache.h
index 8891073..913be6a 100644
--- a/cache.h
+++ b/cache.h
@@ -392,6 +392,7 @@ extern int receive_keep_pack(int fd[2],
/* 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);
diff --git a/diff.c b/diff.c
index 6198a61..16d47bf 100644
--- a/diff.c
+++ b/diff.c
@@ -175,7 +175,7 @@ int git_diff_ui_config(const char *var,
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;
diff --git a/environment.c b/environment.c
index 558801a..1ce3411 100644
--- a/environment.c
+++ b/environment.c
@@ -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 int dyn_git_object_dir, dyn_git_index_file, dyn_git_graft_file;
static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
--git a/pager.c b/pager.c
index 3f753f6..afd684e 100644
--- a/pager.c
+++ b/pager.c
@@ -14,6 +14,10 @@ static int git_pager_config(const char *
pager = strdup(value);
return 0;
}
+ if (!strcmp(var, "pager.color")) {
+ pager_use_color = git_config_bool(var,value);
+ return 0;
+ }
return 0;
}
--
1.4.2.rc2.g91b7
next reply other threads:[~2006-07-29 22:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-29 22:27 Matthias Lederhofer [this message]
2006-07-29 23:15 ` [PATCH] pager: config variable pager.color Johannes Schindelin
2006-07-30 0:43 ` Matthias Lederhofer
2006-07-30 9:33 ` Johannes Schindelin
2006-07-31 0:43 ` Junio C Hamano
2006-07-31 8:55 ` Juergen Ruehle
2006-07-31 9:53 ` Junio C Hamano
2006-07-31 12:02 ` Matthias Lederhofer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1G6xHb-0008Rw-G2@moooo.ath.cx \
--to=matled@gmx.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).