From: Junio C Hamano Date: Thu, 14 May 2026 21:26:27 GMT Subject: Re: [PATCH] config: suggest the correct form when key contains "=" Message-ID: In-Reply-To: "Harald Nordgren via GitGitGadget" writes: > From: Harald Nordgren > > 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.