summaryrefslogtreecommitdiff
path: root/color.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2011-02-25 23:09:41 -0600
committerJunio C Hamano <gitster@pobox.com>2011-03-08 12:12:42 -0800
commitbecbdae82bb8bb193c2f1e9d8b32a60bdef8b0e4 (patch)
tree66c92c293581575690b26ab211b6d880a45d8eab /color.c
parent26db0f2e3afc043e184a5e0ce5eb7c53aeb1f644 (diff)
downloadgit-becbdae82bb8bb193c2f1e9d8b32a60bdef8b0e4.tar.gz
wt-status: add helpers for printing wt-status lines
Introduce status_printf{,_ln,_more} wrapper functions around color_vfprintf() which take care of adding "#" to the beginning of status lines automatically. The semantics: - status_printf() is just like color_fprintf() but it adds a "# " at the beginning of each line of output; - status_printf_ln() is a convenience function that additionally adds "\n" at the end; - status_printf_more() is a variant of status_printf() used to continue lines that have already started. It suppresses the "#" at the beginning of the first line. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'color.c')
-rw-r--r--color.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/color.c b/color.c
index 6a5a54ec66..417cf8fb28 100644
--- a/color.c
+++ b/color.c
@@ -175,6 +175,15 @@ int git_color_default_config(const char *var, const char *value, void *cb)
return git_default_config(var, value, cb);
}
+void color_print_strbuf(FILE *fp, const char *color, const struct strbuf *sb)
+{
+ if (*color)
+ fprintf(fp, "%s", color);
+ fprintf(fp, "%s", sb->buf);
+ if (*color)
+ fprintf(fp, "%s", GIT_COLOR_RESET);
+}
+
static int color_vfprintf(FILE *fp, const char *color, const char *fmt,
va_list args, const char *trail)
{