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

Re: [PATCH v3] config: suggest the correct form when key contains "=" in set context

From
Junio C Hamano <gitster@pobox.com>
Date
May 25, 2026, 09:15 UTC
Message-ID
<xmqqecizetoh.fsf@gitster.g>
In-Reply-To
<pull.2302.v3.git.git.1779697995418.gitgitgadget@gmail.com>
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> Emit a "did you mean ..." hint suggesting the split form.  Restrict it
> to plausible-set contexts ("git config set", bare "git config <key>",
> and their 2-arg forms); explicit "get"/"unset" keep the existing error.

I understand that it would be a good idea to give this warning against these two where $A is an arbitrary string with at least one dot in it (making it a likely variable name), and $B is an arbitrary string that may contain anything:

    git config set "$A=$B"
    git config "$A=$B"

It is plausible that the user wanted to make the value of the variable "$A" to "$B", so telling them the right syntax would be valuable.

If "$A" is a syntactically valid variable name, then I would imagine that we want to say something like this:

    $ git config set "$A=$B"
    error: missing value to set to the variable "$A=$B"
    hint: did you mean 'git config set "$A" "$B"'?

If "$A" is *not* a syntactically valid variable name, then giving a hint to try to assing to it is a counter-productive. Ideally we probably want something like:

    $ git config set "foo=bar"
    error: missing value to set to a variable with an invalid name 'foo=bar'

It is pointless to say the user may have meant "git config set foo bar", as "foo" is clearly not a valid variable.

I do not understand what you mean by "their 2-arg forms". Do you mean

    git config set "$A=$B" "$C"

by that? If so, I doubt that user meant an assignment to "$A" by this form with explicit "set". If "$A=$B" is a variable whose name is valid (i.e. three-level name whose the second level component contains a "="), we should just take it as asked. E.g.,

    git config set "foo.bar=baz.boo" "some-string"

needs no hand holding. But if "$A=$B" is not a valid variable name, we should just complain that the user is trying to assign to a variable with an invalid name.

    $ git config set "foo.bar=baz" "some-string"
    error: setting to a variable with invalid name 'foo.bar=baz'
I think
    git config "$A=$B" "$C"

that implicitly uses the 'set' verb can be left as an exercise to readers. If "$A=$B" is a valid name, we shouldn't do any complaint. If it is not,

    $ git config "foo.bar=baz" "some-string"
    error: setting to a variable with invalid name 'foo.bar=baz'

It makes it clear to the user that (1) we interpreted the command line to be "implicit set", (2) we interpreted the command line to set variable 'foo.bar=baz', and (3) 'foo.bar=baz' is not a valid name. I do not think there is anything more needed for this case.

Show 7 quoted lines
> "=" is legal inside a subsection, so only fire when "=" lands after
> the last ".".  When the user supplied a separate value, use it in the
> suggestion instead of the suffix after "=":
>
>     $ git config set pull.rebase=false true
>     error: invalid key: pull.rebase=false
>     hint: did you mean "git config set pull.rebase true"?

I really do not think '=' needs *any* special casing in this case. If we used "pull.rebase*false" as the variable instead, the message would say that "pull.rebase*false" is an invalid key. Two important things for this message to convey are (1) the command correctly parsed the command line to mean that the user wants to assign to a variable whose name is 'pull.rebase*false' and (2) that variable name *is* invalid.

If you find the current message suboptimal, I think we should try to clarify the message, as '=' or '*' or any letter that makes the variable name invalid would benefit from the same improvement. Perhaps something like:

    $ git config set pull.rebase*false true
    error: setting to a variable with invalid name: 'pull.rebase*false'
perhaps?
> Signed-off-by: Harald Nordgren <harald.nordgren@kostdoktorn.se>
> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
Interesting.  We typically do not do this.
Previous: Harald Nordgren via GitGitGadgetNext: Harald Nordgren via GitGitGadget
Message 11 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.