public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Tim Landscheidt <tim@tim-landscheidt•de>
To: git@vger•kernel.org
Subject: Inconsistent/buggy behaviour of "git config --add"
Date: Sat, 23 Mar 2024 16:07:58 +0000	[thread overview]
Message-ID: <87o7b5dj8h.fsf@vagabond.tim-landscheidt.de> (raw)

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

             reply	other threads:[~2024-03-23 16:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-23 16:07 Tim Landscheidt [this message]
2024-03-23 17:52 ` Inconsistent/buggy behaviour of "git config --add" Junio C Hamano
2024-03-24 18:57   ` Tim Landscheidt
2024-03-25  0:31     ` brian m. carlson
2024-03-25  7:28     ` Patrick Steinhardt
2024-03-25 18:56       ` 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=87o7b5dj8h.fsf@vagabond.tim-landscheidt.de \
    --to=tim@tim-landscheidt$(echo .)de \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox