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

[PATCH v5 0/2] config: suggest the correct form when key contains "="

From
Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com>
Date
Jun 2, 2026, 13:39 UTC
Message-ID
<pull.2302.v5.git.git.1780407557.gitgitgadget@gmail.com>
In-Reply-To
<pull.2302.v4.git.git.1779823288005.gitgitgadget@gmail.com>
 * New commit config: let git_config_parse_key() validate quietly adds a
   quiet parameter (and an optional store_key) so callers can validate
   without writing to stderr.
 * Validation in die_missing_set_value() now routes through
   git_config_parse_key(key, NULL, NULL, 1) instead of the previous local
   helper.
 * Added tests for 1foo.bar=baz and foo.some.b_r=baz.
Harald Nordgren (2):
  config: let git_config_parse_key() validate quietly
  config: improve diagnostic for "set" with missing value
 builtin/config.c   | 34 ++++++++++++++++++++++++++--
 config.c           | 34 ++++++++++++++++++----------
 config.h           |  2 +-
 submodule-config.c |  2 +-
 t/t1300-config.sh  | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 111 insertions(+), 16 deletions(-)
base-commit: 9ac3f193c05c2237e2b14ebaa1149e9fc8a1abe0
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2302%2FHaraldNordgren%2Fconfig-hint-equals-key-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2302/HaraldNordgren/config-hint-equals-key-v5
Pull-Request: https://github.com/git/git/pull/2302
Range-diff vs v4:
 -:  ---------- > 1:  d938ebf95a config: let git_config_parse_key() validate quietly
 1:  780b99409c ! 2:  e5a2070ee1 config: improve diagnostic for "set" with missing value
     @@ builtin/config.c: static void check_argc(int argc, int min, int max)
       	exit(129);
       }
       
     -+static int is_valid_key(const char *key)
     -+{
     -+	const char *last_dot = strrchr(key, '.');
     -+
     -+	return last_dot && isalpha(last_dot[1]);
     -+}
     -+
      +static NORETURN void die_missing_set_value(const char *arg)
      +{
      +	const char *last_dot = strrchr(arg, '.');
      +	const char *eq = last_dot ? strchr(last_dot + 1, '=') : NULL;
      +	char *prefix = eq ? xstrndup(arg, eq - arg) : NULL;
      +
     -+	if (prefix && is_valid_key(prefix)) {
     ++	if (prefix && !git_config_parse_key(prefix, NULL, NULL, 1)) {
      +		error(_("missing value to set to the variable '%s'"), arg);
      +		advise(_("did you mean \"git config set %s %s\"?"),
      +		       prefix, eq + 1);
     -+	} else if (is_valid_key(arg)) {
     ++	} else if (!git_config_parse_key(arg, NULL, NULL, 1)) {
      +		error(_("missing value to set to the variable '%s'"), arg);
      +	} else {
      +		error(_("missing value to set to a variable with an invalid name '%s'"),
     @@ t/t1300-config.sh: test_expect_success 'invalid key' '
      +	test_grep ! "did you mean" err
      +'
      +
     ++test_expect_success 'set with 1 arg: digit-led section name is valid' '
     ++	test_must_fail git config set 1foo.bar=baz 2>err &&
     ++	test_grep "missing value to set to the variable .1foo\\.bar=baz." err &&
     ++	test_grep "did you mean .git config set 1foo\\.bar baz." err
     ++'
     ++
     ++test_expect_success 'set with 1 arg: subsection plus invalid variable name' '
     ++	test_must_fail git config set foo.some.b_r=baz 2>err &&
     ++	test_grep "missing value to set to a variable with an invalid name .foo\\.some\\.b_r=baz." err &&
     ++	test_grep ! "did you mean" err
     ++'
     ++
      +test_expect_success 'set with 1 arg of valid key reports missing value' '
      +	test_must_fail git config set pull.rebase 2>err &&
      +	test_grep "missing value to set to the variable .pull\\.rebase." err &&
-- 
gitgitgadget
Previous: Junio C HamanoNext: Harald Nordgren via GitGitGadget
Message 16 of 26 in “config: suggest the correct form when key contains "="”
  1. config: suggest the correct form when key contains "="Harald Nordgren via GitGitGadget, May 13, 2026
  2. Junio C HamanoMay 14, 2026
  3. fetch: add fetch.pruneLocalBranches configHarald Nordgren, May 14, 2026
  4. Junio C HamanoMay 15, 2026
  5. Email issuesHarald Nordgren, May 15, 2026
  6. Kristoffer HaugsbakkMay 15, 2026
  7. Harald NordgrenMay 15, 2026
  8. Harald NordgrenMay 16, 2026
  9. config: suggest the correct form when key contains "=" in set contextHarald Nordgren via GitGitGadget, May 16, 2026
  10. config: suggest the correct form when key contains "=" in set contextHarald Nordgren via GitGitGadget, May 25, 2026
  11. Junio C HamanoMay 25, 2026
  12. config: improve diagnostic for "set" with missing valueHarald Nordgren via GitGitGadget, May 26, 2026
  13. Harald NordgrenMay 26, 2026
  14. Junio C HamanoJun 1, 2026
  15. Junio C HamanoJun 1, 2026
  16. 0/2 config: suggest the correct form when key contains "="Harald Nordgren via GitGitGadget, Jun 2, 2026
  17. 1/2 config: let git_config_parse_key() validate quietlyHarald Nordgren via GitGitGadget, Jun 2, 2026
  18. Junio C HamanoJun 2, 2026
  19. Harald NordgrenJun 2, 2026
  20. Junio C HamanoJun 4, 2026
  21. 2/2 config: improve diagnostic for "set" with missing valueHarald Nordgren via GitGitGadget, Jun 2, 2026
  22. Junio C HamanoJun 2, 2026
  23. 0/2 config: suggest the correct form when key contains "="Harald Nordgren via GitGitGadget, Jun 2, 2026
  24. 1/2 config: add git_config_key_is_valid() for quiet validationHarald Nordgren via GitGitGadget, Jun 2, 2026
  25. 2/2 config: improve diagnostic for "set" with missing valueHarald Nordgren via GitGitGadget, Jun 2, 2026
  26. Junio C HamanoJun 4, 2026

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.