X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=color.c;h=1b00554dd50d2960b4e66f229b0d2d0da8eb8c28;hb=302ad7a9930a34413418b6436f96826070367647;hp=e8bcac0a79a27ee093f3d5a92013780cf52eb9da;hpb=581b26c82dd3232b052d5228a1ba2ea3cc03dc28;p=git.git diff --git a/color.c b/color.c index e8bcac0a7..1b00554dd 100644 --- a/color.c +++ b/color.c @@ -146,6 +146,9 @@ int git_config_colorbool(const char *var, const char *value, int stdout_is_tty) goto auto_color; } + if (!var) + return -1; + /* Missing or explicit false to turn off colorization */ if (!git_config_bool(var, value)) return 0; @@ -208,31 +211,3 @@ int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...) va_end(args); return r; } - -/* - * This function splits the buffer by newlines and colors the lines individually. - * - * Returns 0 on success. - */ -int color_fwrite_lines(FILE *fp, const char *color, - size_t count, const char *buf) -{ - if (!*color) - return fwrite(buf, count, 1, fp) != 1; - while (count) { - char *p = memchr(buf, '\n', count); - if (p != buf && (fputs(color, fp) < 0 || - fwrite(buf, p ? p - buf : count, 1, fp) != 1 || - fputs(GIT_COLOR_RESET, fp) < 0)) - return -1; - if (!p) - return 0; - if (fputc('\n', fp) < 0) - return -1; - count -= p + 1 - buf; - buf = p + 1; - } - return 0; -} - -