git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Inconsistent/buggy behaviour of "git config --add"

From
TLTim Landscheidt <tim@tim-landscheidt.de>
Date
Mar 23, 2024, 16:07 UTC
Message-ID
<87o7b5dj8h.fsf@vagabond.tim-landscheidt.de>
Hi,

with Git 2.44.0 on Fedora 39, the behaviour of "git config --add", i. e., adding multiple lines to a configuration key, is inconsistent and/or buggy:

| # git config section.key value0
| # git config --add section.key value1
| # cat .git/config
| [core]
|         repositoryformatversion = 0
|         filemode = true
|         bare = false
|         logallrefupdates = true
| [section]
|         key = value0
|         key = value1
| # git config section.key --add value2
| # cat .git/config
| [core]
|         repositoryformatversion = 0
|         filemode = true
|         bare = false
|         logallrefupdates = true
| [section]
|         key = value0
|         key = value1
|         key = --add
| # git config section.key --add
| warning: section.key has multiple values
| error: cannot overwrite multiple values with a single value
|        Use a regexp, --add or --replace-all to change section.key.
| #

So on one hand, "--add" must be given before the key to add a line, but if on the other hand one passes the option after the key and before the value, it is literally taken as the value and the value does not seem to be interpreted as a value-pattern, either. However, if the value is missing, Git correctly recognizes that this does not make sense.

My expectation of least surprise is that "git config section.key --add value" should be equivalent to "git config --add section.key value".

If that is not possible, I would expect "git config section.key --add value2" to mean "change the values of section.key to '--add' where they currently match the value-pattern of 'value2'".

Tim
Next: Junio C Hamano
Message 1 of 6 in “Inconsistent/buggy behaviour of "git config --add"”
  1. Tim LandscheidtMar 23, 2024
  2. Junio C HamanoMar 23, 2024
  3. Tim LandscheidtMar 24, 2024
  4. brian m. carlsonMar 25, 2024
  5. Patrick SteinhardtMar 25, 2024
  6. Junio C HamanoMar 25, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.