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

Re: [PATCH 1/2] config: improve error message for boolean config

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 18, 2020, 19:14 UTC
Message-ID
<xmqqpn6ilwwx.fsf@gitster.c.googlers.com>
In-Reply-To
<15b794ad-6eae-6de1-3328-9b814e8e2605@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
> This patch improves things for boolean config keys  but
> git_config_bool_or_int() is used by status.submoduleSummary, merge.log 
> and commit.verbose which can be either a number or a boolean (where a
> boolean generally means use a default number).

Excellent point. The rephrasing done by the patch as-is will be a regression.

> It would be a more 
> invasive change but I wonder if it would be better for
> git_config_bool() to have it's own error message rather sharing it
> with git_config_bool_or_int().

You'd probably need a variant of die_bad_numer(), with an untested patch like below.

 config.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/config.c b/config.c
index 8db9c77098..801d944d2b 100644
--- a/config.c
+++ b/config.c
@@ -1097,7 +1097,10 @@ int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
 		return v;
 	}
 	*is_bool = 0;
-	return git_config_int(name, value);
+
+	if (!git_parse_int(value, &v))
+		die_bad_number_or_bool(name, value);
+	return v;
 }
 
 int git_config_bool(const char *name, const char *value)
Previous: Phillip WoodNext: Andrew Klotz via GitGitGadget
Message 5 of 13 in “config: improve error message for boolean config”
  1. 0/2 config: improve error message for boolean configAndrew Klotz via GitGitGadget, Sep 18, 2020
  2. 1/2 config: improve error message for boolean configAndrew Klotz via GitGitGadget, Sep 18, 2020
  3. Jeff KingSep 18, 2020
  4. Phillip WoodSep 18, 2020
  5. Junio C HamanoSep 18, 2020
  6. 2/2 formatting for error messagesAndrew Klotz via GitGitGadget, Sep 18, 2020
  7. Junio C HamanoSep 18, 2020
  8. config: improve error message for boolean configAndrew Klotz via GitGitGadget, Feb 9, 2021
  9. Jeff KingFeb 9, 2021
  10. Junio C HamanoFeb 9, 2021
  11. config: improve error message for boolean configAndrew Klotz via GitGitGadget, Feb 11, 2021
  12. Jeff KingFeb 12, 2021
  13. Junio C HamanoFeb 12, 2021

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.