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

Re: [PATCH] config: suggest the correct form when key contains "="

From
Junio C Hamano <gitster@pobox.com>
Date
May 14, 2026, 21:26 UTC
Message-ID
<xmqqqzndel8c.fsf@gitster.g>
In-Reply-To
<pull.2302.git.git.1778680725459.gitgitgadget@gmail.com>
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 16 quoted lines
> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> When a user types "git config foo.bar=baz", git_config_parse_key()
> rejects the key with "error: invalid key: foo.bar=baz" but gives no
> indication of what the user should have written.  The mistake is a
> common one for users who reach for INI-file syntax or for the
> "--flag=value" convention used by other command-line tools.
>
> Since "=" is never a valid character in a config key, treat its
> presence as a strong signal of this specific mistake and follow the
> error with a one-line suggestion in the "(did you mean ...)" style
> used elsewhere in git, e.g.:
>
>     $ git config pull.rebase=false
>     error: invalid key: pull.rebase=false
>       (did you mean "git config set pull.rebase false"?)
If the command line were
	git config get foo.bar=baz
	git config set foo.bar=baz nitfol
we shouldn't give an extra "did you mean?" at all.
The only cases you may want to do the "did you mean?" I think are
	git config foo.bar=baz
	git config set foo.bar=baz

And I think git_config_parse_key() is at a way too low level to tell in what context we are seeing this faulty key to guess end-user's intention to limit our "did you mean?"

I also wonder if, given that "=" in anywhere other than three-level names, is invalid, we should just start accept

	git config foo.bar=baz
	git config set foo.bar=baz
and interpret them as
	git config set foo.bar baz
We of course need to be careful about non-invalid keys, i.e.
	git config foo.bar=baz.boo
is a request to read the value of that named variable, i.e.
	[foo "bar=baz"]
		boo = its value

so either you start offering unsolicited "did you mean?" or accepting tokens with '=' in them as new style "set", you need to be extra careful not to trigger a false positive.

Previous: Harald Nordgren via GitGitGadgetNext: Harald Nordgren
Message 2 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.