diff options
author | Junio C Hamano <gitster@pobox.com> | 2007-12-12 16:52:51 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-12-12 16:52:51 -0800 |
commit | cfa97ae141160486dbe8a786487bcaa965a160f0 (patch) | |
tree | 63ff6f83e7bc0d6588aaa42c7f0ab15c7b791aa4 | |
parent | disable t9119 for now. (diff) | |
parent | git-svn: get color config from --get-colorbool (diff) | |
download | tgif-cfa97ae141160486dbe8a786487bcaa965a160f0.tar.xz |
Merge branch 'jk/svn-color'
* jk/svn-color:
git-svn: get color config from --get-colorbool
Support GIT_PAGER_IN_USE environment variable
-rw-r--r-- | cache.h | 2 | ||||
-rw-r--r-- | color.c | 2 | ||||
-rw-r--r-- | environment.c | 1 | ||||
-rwxr-xr-x | git-svn.perl | 35 | ||||
-rw-r--r-- | pager.c | 15 |
5 files changed, 18 insertions, 37 deletions
@@ -608,7 +608,7 @@ extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char /* pager.c */ extern void setup_pager(void); extern char *pager_program; -extern int pager_in_use; +extern int pager_in_use(void); extern int pager_use_color; extern char *editor_program; @@ -135,7 +135,7 @@ int git_config_colorbool(const char *var, const char *value, int stdout_is_tty) auto_color: if (stdout_is_tty < 0) stdout_is_tty = isatty(1); - if (stdout_is_tty || (pager_in_use && pager_use_color)) { + if (stdout_is_tty || (pager_in_use() && pager_use_color)) { char *term = getenv("TERM"); if (term && strcmp(term, "dumb")) return 1; diff --git a/environment.c b/environment.c index f3e3d4138d..18a1c4eec4 100644 --- a/environment.c +++ b/environment.c @@ -31,7 +31,6 @@ size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE; size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT; size_t delta_base_cache_limit = 16 * 1024 * 1024; char *pager_program; -int pager_in_use; int pager_use_color = 1; char *editor_program; char *excludes_file; diff --git a/git-svn.perl b/git-svn.perl index 9f884eb213..1c42c558c4 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -3969,39 +3969,7 @@ sub cmt_showable { } sub log_use_color { - return 1 if $color; - my ($dc, $dcvar); - $dcvar = 'color.diff'; - $dc = `git-config --get $dcvar`; - if ($dc eq '') { - # nothing at all; fallback to "diff.color" - $dcvar = 'diff.color'; - $dc = `git-config --get $dcvar`; - } - chomp($dc); - if ($dc eq 'auto') { - my $pc; - $pc = `git-config --get color.pager`; - if ($pc eq '') { - # does not have it -- fallback to pager.color - $pc = `git-config --bool --get pager.color`; - } - else { - $pc = `git-config --bool --get color.pager`; - if ($?) { - $pc = 'false'; - } - } - chomp($pc); - if (-t *STDOUT || (defined $pager && $pc eq 'true')) { - return ($ENV{TERM} && $ENV{TERM} ne 'dumb'); - } - return 0; - } - return 0 if $dc eq 'never'; - return 1 if $dc eq 'always'; - chomp($dc = `git-config --bool --get $dcvar`); - return ($dc eq 'true'); + return $color || Git->repository->get_colorbool('color.diff'); } sub git_svn_log_cmd { @@ -4060,6 +4028,7 @@ sub config_pager { } elsif (length $pager == 0 || $pager eq 'cat') { $pager = undef; } + $ENV{GIT_PAGER_IN_USE} = defined($pager); } sub run_pager { @@ -5,6 +5,8 @@ * something different on Windows, for example. */ +static int spawned_pager; + static void run_pager(const char *pager) { /* @@ -41,7 +43,7 @@ void setup_pager(void) else if (!*pager || !strcmp(pager, "cat")) return; - pager_in_use = 1; /* means we are emitting to terminal */ + spawned_pager = 1; /* means we are emitting to terminal */ if (pipe(fd) < 0) return; @@ -70,3 +72,14 @@ void setup_pager(void) die("unable to execute pager '%s'", pager); exit(255); } + +int pager_in_use(void) +{ + const char *env; + + if (spawned_pager) + return 1; + + env = getenv("GIT_PAGER_IN_USE"); + return env ? git_config_bool("GIT_PAGER_IN_USE", env) : 0; +} |