X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=color.c;h=cb70340420b6285786b988d4a98d2023a37d4ffc;hb=6bc4c72132adbdc06c428f86a96f27e4f8173b99;hp=97cfbda31ac02b7e4fe747052c28821a34ee0165;hpb=08e1812db1585c450bfe7f41e7106222346c88da;p=git.git diff --git a/color.c b/color.c index 97cfbda31..cb7034042 100644 --- a/color.c +++ b/color.c @@ -17,7 +17,7 @@ static int parse_color(const char *name, int len) return i - 1; } i = strtol(name, &end, 10); - if (*name && !*end && i >= -1 && i <= 255) + if (end - name == len && i >= -1 && i <= 255) return i; return -2; } @@ -116,7 +116,7 @@ bad: die("bad config value '%s' for variable '%s'", value, var); } -int git_config_colorbool(const char *var, const char *value) +int git_config_colorbool(const char *var, const char *value, int stdout_is_tty) { if (value) { if (!strcasecmp(value, "never")) @@ -133,7 +133,9 @@ int git_config_colorbool(const char *var, const char *value) /* any normal truth value defaults to 'auto' */ auto_color: - if (isatty(1) || (pager_in_use && pager_use_color)) { + if (stdout_is_tty < 0) + stdout_is_tty = isatty(1); + if (stdout_is_tty || (pager_in_use() && pager_use_color)) { char *term = getenv("TERM"); if (term && strcmp(term, "dumb")) return 1;