git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/3] Move color option parsing out of diff.c and into color.[ch]

From
Junio C Hamano <junkio@cox.net>
Date
Sep 7, 2006, 23:56 UTC
Message-ID
<7vfyf3s01w.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060907063559.GB17083@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> +#include <stdarg.h>
> +
> +#define COLOR_RESET "\033[m"
> +
> +static int
> +parse_color(const char *name, int len)
> +{
Style (applies to all functions you moved to this new file).

Some school of programming teach us to start the function name at the beginning of the line, separate from its type. They say that would make "grep '^parse_color'" to work better.

That happens to be the way I was taught (actually it was a bit more strange that return type was to be indented by one TAB, so it looked like this:

		static int
	parse_color(const char *name, int len)

). But git style is the kernel style, and I refrain from doing that myself.

	static int parse_color(const char *name, int len)
	{
        	...
Show 19 quoted lines
> +int
> +git_config_colorbool(const char *var, const char *value)
> +{
> +	if (!value)
> +		return 1;
> +	if (!strcasecmp(value, "auto")) {
> +		if (isatty(1) || (pager_in_use && pager_use_color)) {
> +			char *term = getenv("TERM");
> +			if (term && strcmp(term, "dumb"))
> +				return 1;
> +		}
> +		return 0;
> +	}
> +	if (!strcasecmp(value, "never"))
> +		return 0;
> +	if (!strcasecmp(value, "always"))
> +		return 1;
> +	return git_config_bool(var, value);
> +}
> +int
> +color_printf(const char *color, const char *fmt, ...) {
Style.
	int color_printf(const char *color, const char *fmt, ...)
	{
		...
Previous: Jeff KingNext: Jeff King
Message 2 of 3 in “Move color option parsing out of diff.c and into color.[ch]”
  1. 2/3 Move color option parsing out of diff.c and into color.[ch]Jeff King, Sep 7, 2006
  2. Junio C HamanoSep 7, 2006
  3. Jeff KingSep 8, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.