git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Avery Pennarun <apenwarr@gmail.com>
To: Disc Magnet <discmagnet@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Can't assign user.name to "E F" in git config
Date: Mon, 29 Mar 2010 16:55:59 -0400	[thread overview]
Message-ID: <32541b131003291355k5f93b251vded347e37315fee5@mail.gmail.com> (raw)
In-Reply-To: <308d4701003291332s500cbbci68e10a784ac1aa81@mail.gmail.com>

On Mon, Mar 29, 2010 at 4:32 PM, Disc Magnet <discmagnet@gmail.com> wrote:
> I've never done a git init and I don't have any .git directory in the
> current directory. I get warnings in the following example. Moreover,
> I can't assign user.name to "E F".

Take a look at 'man git-config' and search for "value_regex".  The
behaviour is incredibly non-obvious, but git-config is working as
documented:

> humpty@wall:~/work$ rm ~/.gitconfig
> humpty@wall:~/work$ git config --global user.name A B
> humpty@wall:~/work$ git config --global user.name C D
> humpty@wall:~/work$ git config --global user.name "E F"
> warning: user.name has multiple values
> humpty@wall:~/work$ git config -l
> user.name=A
> user.name=C
> humpty@wall:~/work$ cat ~/.gitconfig
> [user]
>        name = A
>        name = C

The A B line means "remove any user.name options containing B and then
add A".  Similarly with C D.  But the "E F" line means "there is only
one value of user.name, and it should be E F."  At that time,
user.name has more than one value, so git assumes you've made a
mistake and refuses to perform the operation (which would have
resulted in potentially many lost lines of config information).

You can fix it with "git config --global --unset-all user.name".

> However, everything works fine here.
>
> humpty@wall:~/work$ rm ~/.gitconfig
> humpty@wall:~/work$ git config --global user.name A
> humpty@wall:~/work$ git config --global user.name C
> humpty@wall:~/work$ git config --global user.name "E F"
> humpty@wall:~/work$ git config -l
> user.name=E F
> humpty@wall:~/work$ cat ~/.gitconfig
> [user]
>        name = E F

In the above, you never created multiple values, because the first two
lines didn't have extra parameters.

> Is this an expected behavior or is it a bug?

I didn't know about it before, and to be honest, it seems a little
insane.  But I found it by reading the man page, so it's clearly
"expected" behaviour, in the sense that we're told to expect it.  And
now that it exists, removing it would break backward compatibility.

Have fun,

Avery

      reply	other threads:[~2010-03-29 20:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-29 20:32 Can't assign user.name to "E F" in git config Disc Magnet
2010-03-29 20:55 ` Avery Pennarun [this message]

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=32541b131003291355k5f93b251vded347e37315fee5@mail.gmail.com \
    --to=apenwarr@gmail.com \
    --cc=discmagnet@gmail.com \
    --cc=git@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).