@@ -76,22 +76,46 @@ int git_color_config(const char *var, const char *value, void *cb);
7676int git_color_default_config (const char * var , const char * value , void * cb );
7777
7878/*
79- * Set the color buffer (which must be COLOR_MAXLEN bytes)
80- * to the raw color bytes; this is useful for initializing
81- * default color variables.
79+ * Parse a config option, which can be a boolean or one of
80+ * "never", "auto", "always". Return a constant of
81+ * GIT_COLOR_NEVER for "never" or negative boolean,
82+ * GIT_COLOR_ALWAYS for "always" or a positive boolean,
83+ * and GIT_COLOR_AUTO for "auto".
8284 */
83- void color_set (char * dst , const char * color_bytes );
84-
8585int git_config_colorbool (const char * var , const char * value );
86+
87+ /*
88+ * Return a boolean whether to use color, where the argument 'var' is
89+ * one of GIT_COLOR_UNKNOWN, GIT_COLOR_NEVER, GIT_COLOR_ALWAYS, GIT_COLOR_AUTO.
90+ */
8691int want_color (int var );
92+
93+ /*
94+ * Translate a Git color from 'value' into a string that the terminal can
95+ * interpret and store it into 'dst'. The Git color values are of the form
96+ * "foreground [background] [attr]" where fore- and background can be a color
97+ * name ("red"), a RGB code (#0xFF0000) or a 256-color-mode from the terminal.
98+ */
8799int color_parse (const char * value , char * dst );
88100int color_parse_mem (const char * value , int len , char * dst );
101+
102+ /*
103+ * Output the formatted string in the specified color (and then reset to normal
104+ * color so subsequent output is uncolored). Omits the color encapsulation if
105+ * `color` is NULL. The `color_fprintf_ln` prints a new line after resetting
106+ * the color. The `color_print_strbuf` prints the contents of the given
107+ * strbuf (BUG: but only up to its first NUL character).
108+ */
89109__attribute__((format (printf , 3 , 4 )))
90110int color_fprintf (FILE * fp , const char * color , const char * fmt , ...);
91111__attribute__((format (printf , 3 , 4 )))
92112int color_fprintf_ln (FILE * fp , const char * color , const char * fmt , ...);
93113void color_print_strbuf (FILE * fp , const char * color , const struct strbuf * sb );
94114
115+ /*
116+ * Check if the given color is GIT_COLOR_NIL that means "no color selected".
117+ * The caller needs to replace the color with the actual desired color.
118+ */
95119int color_is_nil (const char * color );
96120
97121#endif /* COLOR_H */
0 commit comments