All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,
	 Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
	 Harald Nordgren <haraldnordgren@gmail.com>
Subject: Re: [PATCH v3] config: suggest the correct form when key contains "=" in set context
Date: Mon, 25 May 2026 18:15:42 +0900	[thread overview]
Message-ID: <xmqqecizetoh.fsf@gitster.g> (raw)
In-Reply-To: <pull.2302.v3.git.git.1779697995418.gitgitgadget@gmail.com> (Harald Nordgren via GitGitGadget's message of "Mon, 25 May 2026 08:33:15 +0000")

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

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

  reply	other threads:[~2026-05-25  9:15 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 13:58 [PATCH] config: suggest the correct form when key contains "=" Harald Nordgren via GitGitGadget
2026-05-14 21:26 ` Junio C Hamano
2026-05-14 22:16   ` [PATCH] fetch: add fetch.pruneLocalBranches config Harald Nordgren
2026-05-15  1:28     ` Junio C Hamano
2026-05-15  7:56       ` Email issues Harald Nordgren
2026-05-15 12:02         ` Kristoffer Haugsbakk
2026-05-15  9:39       ` [PATCH] fetch: add fetch.pruneLocalBranches config Harald Nordgren
2026-05-16 12:51   ` [PATCH] config: suggest the correct form when key contains "=" Harald Nordgren
2026-05-16 12:52 ` [PATCH v2] config: suggest the correct form when key contains "=" in set context Harald Nordgren via GitGitGadget
2026-05-25  8:33   ` [PATCH v3] " Harald Nordgren via GitGitGadget
2026-05-25  9:15     ` Junio C Hamano [this message]
2026-05-26 19:21     ` [PATCH v4] config: improve diagnostic for "set" with missing value Harald Nordgren via GitGitGadget
2026-05-26 19:24       ` Harald Nordgren
2026-06-01 23:45       ` Junio C Hamano
2026-06-01 23:53       ` Junio C Hamano
2026-06-02 13:39       ` [PATCH v5 0/2] config: suggest the correct form when key contains "=" Harald Nordgren via GitGitGadget
2026-06-02 13:39         ` [PATCH v5 1/2] config: let git_config_parse_key() validate quietly Harald Nordgren via GitGitGadget
2026-06-02 14:08           ` Junio C Hamano
2026-06-02 16:31             ` Harald Nordgren
2026-06-04  1:09               ` Junio C Hamano
2026-06-02 13:39         ` [PATCH v5 2/2] config: improve diagnostic for "set" with missing value Harald Nordgren via GitGitGadget
2026-06-02 14:18           ` Junio C Hamano
2026-06-02 18:43         ` [PATCH v6 0/2] config: suggest the correct form when key contains "=" Harald Nordgren via GitGitGadget
2026-06-02 18:43           ` [PATCH v6 1/2] config: add git_config_key_is_valid() for quiet validation Harald Nordgren via GitGitGadget
2026-06-02 18:43           ` [PATCH v6 2/2] config: improve diagnostic for "set" with missing value Harald Nordgren via GitGitGadget
2026-06-04  1:09           ` [PATCH v6 0/2] config: suggest the correct form when key contains "=" Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

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

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.