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

Re: [PATCH/RFC] ignore unknown color configuration

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 16, 2009, 01:29 UTC
Message-ID
<7vy6l3vh8x.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20091212122524.GA17547@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 41 quoted lines
> diff --git a/builtin-branch.c b/builtin-branch.c
> index 05e876e..c87e63b 100644
> --- a/builtin-branch.c
> +++ b/builtin-branch.c
> @@ -65,7 +65,7 @@ static int parse_branch_color_slot(const char *var, int ofs)
>  		return BRANCH_COLOR_LOCAL;
>  	if (!strcasecmp(var+ofs, "current"))
>  		return BRANCH_COLOR_CURRENT;
> -	die("bad config variable '%s'", var);
> +	return -1;
>  }
>  
>  static int git_branch_config(const char *var, const char *value, void *cb)
> @@ -76,6 +76,8 @@ static int git_branch_config(const char *var, const char *value, void *cb)
>  	}
>  	if (!prefixcmp(var, "color.branch.")) {
>  		int slot = parse_branch_color_slot(var, 13);
> +		if (slot < 0)
> +			return 0;
>  		if (!value)
>  			return config_error_nonbool(var);
>  		color_parse(value, var, branch_colors[slot]);
> diff --git a/builtin-commit.c b/builtin-commit.c
> index e93a647..326cd63 100644
> --- a/builtin-commit.c
> +++ b/builtin-commit.c
> @@ -890,7 +890,7 @@ static int parse_status_slot(const char *var, int offset)
>  		return WT_STATUS_NOBRANCH;
>  	if (!strcasecmp(var+offset, "unmerged"))
>  		return WT_STATUS_UNMERGED;
> -	die("bad config variable '%s'", var);
> +	return -1;
>  }
>  
>  static int git_status_config(const char *k, const char *v, void *cb)
> @@ -910,6 +910,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
>  	}
>  	if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
>  		int slot = parse_status_slot(k, 13);
> +		if (slot < 0)
> +			return -1;

Shouldn't this return 0, to say "we handled it (by ignoring), don't worry", instead of saying "hey it's error" by returning -1? That's what is done on the "diff" side below...

Show 13 quoted lines
> diff --git a/diff.c b/diff.c
> index d952686..08bbd3e 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -122,6 +122,8 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
>  
>  	if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
>  		int slot = parse_diff_color_slot(var, 11);
> +		if (slot < 0)
> +			return 0;
>  		if (!value)
>  			return config_error_nonbool(var);
>  		color_parse(value, var, diff_colors[slot]);
Previous: Jeff KingNext: Jeff King
Message 7 of 8 in “ignore unknown color configuration”
  1. ignore unknown color configurationJeff King, Dec 12, 2009
  2. Junio C HamanoDec 12, 2009
  3. Jeff KingDec 12, 2009
  4. Junio C HamanoDec 14, 2009
  5. Junio C HamanoDec 16, 2009
  6. Jeff KingDec 16, 2009
  7. Junio C HamanoDec 16, 2009
  8. Jeff KingDec 16, 2009

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.