Skip to content

config: make the suggested "set" command safe to paste - #2457

Draft
HaraldNordgren wants to merge 1 commit into
git:masterfrom
HaraldNordgren:config-set-hint-quote
Draft

HaraldNordgren wants to merge 1 commit into
git:masterfrom
HaraldNordgren:config-set-hint-quote

Conversation

@HaraldNordgren

@HaraldNordgren HaraldNordgren commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

When git config <key>=<value> is given a value with spaces, the suggested command fails when pasted back into a shell. Quote the value when it needs it and put the command on its own line, the way other hints show commands:

$ git config status.comparebranches="@{upstream} @{push}"
error: missing value to set to the variable 'status.comparebranches=@{upstream} @{push}'
hint: did you mean:
hint:
hint: 	git config set status.comparebranches '@{upstream} @{push}'

@HaraldNordgren HaraldNordgren changed the title config: quote the value in the "set" suggestion config: make the suggested "set" command safe to paste Oct 19, 2026
When "git config" is given "<key>=<value>" as a single argument and
the value contains spaces, the suggested command does not work when
pasted back into a shell:

    $ git config status.comparebranches="@{upstream} @{push}"
    error: missing value to set to the variable 'status.comparebranches=@{upstream} @{push}'
    hint: did you mean "git config set status.comparebranches @{upstream} @{push}"?

The shell splits the value into two arguments and the command fails
with "wrong number of arguments".

Quote the value when it needs it, and put the command on a line of
its own the way other hints show commands, so it can be copied
without the surrounding quotes:

    hint: did you mean:
    hint:
    hint:   git config set status.comparebranches '@{upstream} @{push}'

Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant