Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-08-01 10:00:51 +0400
committerJunio C Hamano <junkio@cox.net>2006-08-01 10:00:51 +0400
commit056d6d4e89c9477c4bd4b7c0d81ee51ab5602eb9 (patch)
tree697ec6974c625e9d6a293b785baa402eb345dd52
parent0225de86a484828bd4abfd697d361d2bd37c48f4 (diff)
parentaa086eb813d4fe21aac556a94efe5e29b44d8ca4 (diff)
Merge branch 'ml/pager'
-rw-r--r--Documentation/config.txt4
-rw-r--r--builtin-log.c1
-rw-r--r--cache.h1
-rw-r--r--config.c5
-rw-r--r--diff.c2
-rw-r--r--environment.c1
-rw-r--r--git.c13
7 files changed, 20 insertions, 7 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 465eb13e76..e669003f72 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -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/builtin-log.c b/builtin-log.c
index 82c69d1d05..bba1496bf2 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -34,7 +34,6 @@ static int cmd_log_walk(struct rev_info *rev)
struct commit *commit;
prepare_revision_walk(rev);
- setup_pager();
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
free(commit->buffer);
diff --git a/cache.h b/cache.h
index c575b8a996..b8c21e07b2 100644
--- 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);
diff --git a/config.c b/config.c
index 0ac6aebbbc..82b3562454 100644
--- 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 6a71376483..607c357f5a 100644
--- 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;
diff --git a/environment.c b/environment.c
index 42f39d657e..87162b2572 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 char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
*git_graft_file;
diff --git a/git.c b/git.c
index 7321d6c3f6..d031eb9a18 100644
--- a/git.c
+++ b/git.c
@@ -211,6 +211,7 @@ static int handle_alias(int *argcp, const char ***argv)
const char git_version_string[] = GIT_VERSION;
#define NEEDS_PREFIX 1
+#define USE_PAGER 2
static void handle_internal_command(int argc, const char **argv, char **envp)
{
@@ -218,13 +219,13 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
static struct cmd_struct {
const char *cmd;
int (*fn)(int, const char **, const char *);
- int prefix;
+ int option;
} commands[] = {
{ "version", cmd_version },
{ "help", cmd_help },
- { "log", cmd_log, NEEDS_PREFIX },
- { "whatchanged", cmd_whatchanged, NEEDS_PREFIX },
- { "show", cmd_show, NEEDS_PREFIX },
+ { "log", cmd_log, NEEDS_PREFIX | USE_PAGER },
+ { "whatchanged", cmd_whatchanged, NEEDS_PREFIX | USE_PAGER },
+ { "show", cmd_show, NEEDS_PREFIX | USE_PAGER },
{ "push", cmd_push },
{ "format-patch", cmd_format_patch, NEEDS_PREFIX },
{ "count-objects", cmd_count_objects },
@@ -275,8 +276,10 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
continue;
prefix = NULL;
- if (p->prefix)
+ if (p->option & NEEDS_PREFIX)
prefix = setup_git_directory();
+ if (p->option & USE_PAGER)
+ setup_pager();
if (getenv("GIT_TRACE")) {
int i;
fprintf(stderr, "trace: built-in: git");