Skip to content

config: suggest the correct form when key contains "="#2302

Open
HaraldNordgren wants to merge 1 commit into
git:masterfrom
HaraldNordgren:config-hint-equals-key
Open

config: suggest the correct form when key contains "="#2302
HaraldNordgren wants to merge 1 commit into
git:masterfrom
HaraldNordgren:config-hint-equals-key

Conversation

@HaraldNordgren
Copy link
Copy Markdown
Contributor

@HaraldNordgren HaraldNordgren commented May 13, 2026

  • Hint moved from git_config_parse_key() to a new advise_setting_with_equals() in builtin/config.c; wired only into set and bare paths.
  • Only fires when = is after the last .; 2-arg forms use the user's value.

cc: "Kristoffer Haugsbakk" kristofferhaugsbakk@fastmail.com

@HaraldNordgren
Copy link
Copy Markdown
Contributor Author

/submit

@gitgitgadget-git
Copy link
Copy Markdown

Submitted as pull.2302.git.git.1778680725459.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-2302/HaraldNordgren/config-hint-equals-key-v1

To fetch this version to local tag pr-git-2302/HaraldNordgren/config-hint-equals-key-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-2302/HaraldNordgren/config-hint-equals-key-v1

@gitgitgadget-git
Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> 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.

@gitgitgadget-git
Copy link
Copy Markdown

Harald Nordgren wrote on the Git mailing list (how to reply to this email):

> 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

That sounds good too! Probably even better.


Harald

@HaraldNordgren HaraldNordgren force-pushed the config-hint-equals-key branch from 56eb3ce to 24a8eee Compare May 14, 2026 22:42
@gitgitgadget-git
Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

Harald Nordgren <haraldnordgren@gmail.com> writes:

>> 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
>
> That sounds good too! Probably even better.
>
>
> Harald

Why do I get the above, which apparently is a response to my review
for

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

under this thread?  Am I dealing with some sort of mechanical slop?

@gitgitgadget-git
Copy link
Copy Markdown

Harald Nordgren wrote on the Git mailing list (how to reply to this email):

> Why do I get the above, which apparently is a response to my review
> for
> 
>     [PATCH] config: suggest the correct form when key contains "="
> 
> under this thread?  Am I dealing with some sort of mechanical slop?

I think the problem here is my email sending process is not good. I edit
all the emails in Sublime text, where I keep the same file for all
different threads.

I have the subject line as the first line of the file and like you notice I
forget to change it sometimes.

I keep each of the topics bookmarked like this, 
https://lore.kernel.org/git/xmqqecjdea13.fsf@gitster.g/, and then utilize
that like to send the email

```
  git send-email \
    --in-reply-to=xmqqecjdea13.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=haraldnordgren@gmail.com \
    /path/to/YOUR_REPLY
```

I tried playing with neomutt and and email client replacement, but that
adds the complexity of downloading a new mbox file for each reply, it
didn't seem easier, but maybe it is.

How do you handle emails?


Harald

@gitgitgadget-git
Copy link
Copy Markdown

Harald Nordgren wrote on the Git mailing list (how to reply to this email):

> Why do I get the above, which apparently is a response to my review
> for
>
>     [PATCH] config: suggest the correct form when key contains "="
>
> under this thread?  Am I dealing with some sort of mechanical slop?

(Testing plain text email sending via Gmail for a less error-prone
workflow, does it still add the CC's correctly?)


Harald

@gitgitgadget-git
Copy link
Copy Markdown

"Kristoffer Haugsbakk" wrote on the Git mailing list (how to reply to this email):

On Fri, May 15, 2026, at 09:56, Harald Nordgren wrote:
>> Why do I get the above, which apparently is a response to my review
>> for
>> 
>>     [PATCH] config: suggest the correct form when key contains "="
>> 
>> under this thread?  Am I dealing with some sort of mechanical slop?
>
> I think the problem here is my email sending process is not good. I edit
> all the emails in Sublime text, where I keep the same file for all
> different threads.
>
> I have the subject line as the first line of the file and like you notice I
> forget to change it sometimes.
>
> I keep each of the topics bookmarked like this, 
> https://lore.kernel.org/git/xmqqecjdea13.fsf@gitster.g/, and then utilize
> that like to send the email
>
> ```
>   git send-email \
>     --in-reply-to=xmqqecjdea13.fsf@gitster.g \
>     --to=gitster@pobox.com \
>     --cc=git@vger.kernel.org \
>     --cc=gitgitgadget@gmail.com \
>     --cc=haraldnordgren@gmail.com \
>     /path/to/YOUR_REPLY
> ```
>
> I tried playing with neomutt and and email client replacement, but that
> adds the complexity of downloading a new mbox file for each reply, it
> didn't seem easier, but maybe it is.
>
> How do you handle emails?

I use the Fastmail webmail client for
regular non-patch emails. The only
things it messes up so far is long lines
in replies to patches.

I edit the emails in a text editor. And sometimes
I have left multiple drafts before sending them
and switched them around. Only to see my mistake on the Lore archive later. :)

But by and large it works just fine. I haven't had
the need for a more ergonomic setup.

-- 
Sent from mobile

@gitgitgadget-git
Copy link
Copy Markdown

User "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> has been added to the cc: list.

@HaraldNordgren HaraldNordgren force-pushed the config-hint-equals-key branch 4 times, most recently from 56eb3ce to c69a467 Compare May 16, 2026 12:40
A user who types "git config pull.rebase=false" gets only "error:
invalid key: pull.rebase=false" with no clue what went wrong.

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.

"=" 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"?

Signed-off-by: Harald Nordgren <harald.nordgren@kostdoktorn.se>
@HaraldNordgren HaraldNordgren force-pushed the config-hint-equals-key branch from c69a467 to 40d9eb3 Compare May 16, 2026 12:43
@HaraldNordgren
Copy link
Copy Markdown
Contributor Author

/submit

@gitgitgadget-git
Copy link
Copy Markdown

Submitted as pull.2302.v2.git.git.1778935976330.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-git-2302/HaraldNordgren/config-hint-equals-key-v2

To fetch this version to local tag pr-git-2302/HaraldNordgren/config-hint-equals-key-v2:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-git-2302/HaraldNordgren/config-hint-equals-key-v2

@gitgitgadget-git
Copy link
Copy Markdown

Harald Nordgren wrote on the Git mailing list (how to reply to this email):

> 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

I tried implementing a version to be more liberal in what to accept, but
the implementation became very complex.

Moving in the other direction: show the warning, but try to make it more
correct.

(Also switching over to replying to emails with Gmail with 'plain text
mode'), hopefully there will be less miss-sends that end up on the wrong
topic from now on.)


Harald

@gitgitgadget-git
Copy link
Copy Markdown

This patch series was integrated into seen via e834c48.

@gitgitgadget-git
Copy link
Copy Markdown

This branch is now known as hn/config-typo-advice.

@gitgitgadget-git
Copy link
Copy Markdown

This patch series was integrated into seen via f37a7e6.

@gitgitgadget-git
Copy link
Copy Markdown

This patch series was integrated into seen via 8b3cb0f.

@gitgitgadget-git
Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch hn/config-typo-advice on the Git mailing list:

"git config foo.bar=baz" is not likely to be a request to read the
value of such a variable with '=' in its name; rather it is plausible
that the user meant "git config set foo.bar baz".  Give advice when
giving an error message.

Comments?
source: <pull.2302.v2.git.git.1778935976330.gitgitgadget@gmail.com>

@gitgitgadget-git
Copy link
Copy Markdown

This patch series was integrated into seen via 121864a.

@gitgitgadget-git
Copy link
Copy Markdown

This patch series was integrated into seen via f91f3e5.

@gitgitgadget-git
Copy link
Copy Markdown

This patch series was integrated into seen via 363d16e.

@gitgitgadget-git
Copy link
Copy Markdown

This patch series was integrated into seen via 7db033b.

@gitgitgadget-git
Copy link
Copy Markdown

This patch series was integrated into seen via ce9ce5f.

@gitgitgadget-git
Copy link
Copy Markdown

There was a status update in the "Cooking" section about the branch hn/config-typo-advice on the Git mailing list:

"git config foo.bar=baz" is not likely to be a request to read the
value of such a variable with '=' in its name; rather it is plausible
that the user meant "git config set foo.bar baz".  Give advice when
giving an error message.

Comments?
source: <pull.2302.v2.git.git.1778935976330.gitgitgadget@gmail.com>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant