# [bug report] erroneous suggestion for "--add" option in `git config set` error message

3 messages from 2025-11-20 to 2025-11-24. Participants: Paul Wintz, René Scharfe.
Thread: https://gitlist.dev/t/64519

## Paul Wintz, 2025-11-20 23:39

Subject: [bug report] erroneous suggestion for "--add" option in `git config set` error message
Message-ID: <CADBJ995pDG9R8EJnK5nwWKPWAf-XF5P5KTY+bAx71EhdMvvO6A@mail.gmail.com>
URL: https://gitlist.dev/e/CADBJ995pDG9R8EJnK5nwWKPWAf-XF5P5KTY%2BbAx71EhdMvvO6A%40mail.gmail.com

```
It seems that there is an erroneous suggestion in a `git config set`
error message when setting a value that already has multiple values.
The error message says to use the `--add` option, but this option does
not seem to exist. The `--append` option should be suggested instead.

Steps to reproduce:

1. Create a configuration with multiple values:

    git config set --global test.test 'hello'
    git config set --global --append test.test 'hi'

2. Try to set the value of `test.test`:

    git config set --global test.test 'hi'

An error message is shown:

    warning: test.test has multiple values
    error: cannot overwrite multiple values with a single value
           Use a regexp, --add or --replace-all to change test.test.

3. Following the direction to use `--add` produces an error:

    > git config set --add test.test "aloha"
    error: unknown option `add'

The error message should say `--append` instead of `--add`.

[System Info]
git version:
git version 2.48.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
libcurl: 8.12.1
zlib: 1.3.1
uname: Linux 6.14.0-35-generic #35-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct
11 10:06:31 UTC 2025 x86_64
compiler info: gnuc: 14.2
libc info: glibc: 2.41
$SHELL (typically, interactive shell): /bin/bash


[Enabled Hooks]
post-checkout
post-commit
post-merge
pre-push

--
Paul Wintz, PhD
UCSC Hybrid Systems Laboratory
Hartnell College, Adjunct Faculty
PaulWintz.com

```

## René Scharfe, 2025-11-24 20:22

Subject: Re: [bug report] erroneous suggestion for "--add" option in `git config set` error message
Message-ID: <74cdfd68-f13e-4e45-9aa9-9629429ad0e1@web.de>
URL: https://gitlist.dev/e/74cdfd68-f13e-4e45-9aa9-9629429ad0e1%40web.de
In-Reply-To: <CADBJ995pDG9R8EJnK5nwWKPWAf-XF5P5KTY+bAx71EhdMvvO6A@mail.gmail.com>

```
On 11/21/25 12:39 AM, Paul Wintz wrote:
> It seems that there is an erroneous suggestion in a `git config set`
> error message when setting a value that already has multiple values.
> The error message says to use the `--add` option, but this option does
> not seem to exist. The `--append` option should be suggested instead.
> 
> Steps to reproduce:
> 
> 1. Create a configuration with multiple values:
> 
>     git config set --global test.test 'hello'
>     git config set --global --append test.test 'hi'
> 
> 2. Try to set the value of `test.test`:
> 
>     git config set --global test.test 'hi'
> 
> An error message is shown:
> 
>     warning: test.test has multiple values
>     error: cannot overwrite multiple values with a single value
>            Use a regexp, --add or --replace-all to change test.test.
> 
> 3. Following the direction to use `--add` produces an error:
> 
>     > git config set --add test.test "aloha"
>     error: unknown option `add'
> 
> The error message should say `--append` instead of `--add`.
"git config --append <name> <value>" still works, but your suggestion
is good nevertheless.

--- >8 ---From 066828b25bb7d3086b9bff4188af30e07c7e1c16 Mon Sep 17 00:00:00 2001
Subject: [PATCH] config: fix suggestion for failed set of multi-valued option

The command "git config set <name> <value>" balks at options with
multiple values and suggests to use old-style "git config" actions that
can be used to change some or all of them.  List modern "git config set"
flags instead, as they are more fitting in this context.

Reported-by: Paul Wintz <pwintz@ucsc.edu>
Signed-off-by: René Scharfe <l.s.r@web.de>
---
 builtin/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/config.c b/builtin/config.c
index 75852bd79d..86e0cd77f3 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -985,7 +985,7 @@ static int cmd_config_set(int argc, const char **argv, const char *prefix,
 						     argv[0], comment, value);
 		if (ret == CONFIG_NOTHING_SET)
 			error(_("cannot overwrite multiple values with a single value\n"
-			"       Use a regexp, --add or --replace-all to change %s."), argv[0]);
+			"       Use --value=<pattern>, --append or --all to change %s."), argv[0]);
 	}
 
 	location_options_release(&location_opts);
-- 
2.52.0


```

## René Scharfe, 2025-11-24 20:33

Subject: [PATCH] config: fix suggestion for failed set of multi-valued option
Message-ID: <c09945fe-fee2-47f6-8193-ac60d7245209@web.de>
URL: https://gitlist.dev/e/c09945fe-fee2-47f6-8193-ac60d7245209%40web.de
In-Reply-To: <CADBJ995pDG9R8EJnK5nwWKPWAf-XF5P5KTY+bAx71EhdMvvO6A@mail.gmail.com>

```
The command "git config set <name> <value>" fails for an option that has
multiple values.  List the "git config set" flags that can be used,
instead of old-style "git config" actions.

Reported-by: Paul Wintz <pwintz@ucsc.edu>
Signed-off-by: René Scharfe <l.s.r@web.de>
---
Resent as a pure patch because I messed up the scissors line.

 builtin/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/config.c b/builtin/config.c
index 75852bd79d..86e0cd77f3 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -985,7 +985,7 @@ static int cmd_config_set(int argc, const char **argv, const char *prefix,
 						     argv[0], comment, value);
 		if (ret == CONFIG_NOTHING_SET)
 			error(_("cannot overwrite multiple values with a single value\n"
-			"       Use a regexp, --add or --replace-all to change %s."), argv[0]);
+			"       Use --value=<pattern>, --append or --all to change %s."), argv[0]);
 	}
 
 	location_options_release(&location_opts);
-- 
2.52.0

```
