git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bug: 'git config --local user.email=<alt.email>' fails silently?
@ 2017-04-02  5:47 Knut Omang
  2017-04-02  7:38 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Knut Omang @ 2017-04-02  5:47 UTC (permalink / raw)
  To: git

Hi,

From the documentation I would have expected 

git config --local user.email=alt.email@alt.domain

to create a section 

[user]
	email=alt.email@alt.domain

in the local .git/config.

Instead it returns status 1 with no error message.

Is this intentional?

If I add the [user] section manually, it works as expected/desired:
my commits in that tree uses the alternate mail address.

git --version
git version 2.7.4

Thanks,
Knut Omang

-- 
Knut Omang, Ph.D
Principal Software Engineer
Oracle Linux and Virtualization Engineering
ORACLE Norway | Olaf Helsets vei 6 | 0694 Oslo
Email: knut.omang@oracle.com | Phone:  +47 41 46 22 10


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug: 'git config --local user.email=<alt.email>' fails silently?
  2017-04-02  5:47 Bug: 'git config --local user.email=<alt.email>' fails silently? Knut Omang
@ 2017-04-02  7:38 ` Jeff King
  2017-04-02  7:53   ` Knut Omang
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2017-04-02  7:38 UTC (permalink / raw)
  To: Knut Omang; +Cc: git

On Sun, Apr 02, 2017 at 07:47:23AM +0200, Knut Omang wrote:

> From the documentation I would have expected 
> 
> git config --local user.email=alt.email@alt.domain
> 
> to create a section 
> 
> [user]
> 	email=alt.email@alt.domain
> 
> in the local .git/config.

When it sees one argument, git-config treats that argument as a key to
be retrieved. When given two, the second is a value to be set. E.g.:

  $ git config foo.bar
  $ git config foo.bar some-value
  $ git config foo.bar
  some-value

So your command was interpreted as a request to fetch the value, which
doesn't exist.

> Instead it returns status 1 with no error message.

Hopefully that explains the response you saw; we do not emit an error
message when a key isn't found, which makes it easy for scripts to do
things like:

  value=$(git config foo.bar || echo default-value)

without being unnecessarily noisy.

Usually we'd catch an error like yours and complain, because the key is
syntactically invalid ("=" is not generally allowed in key names):

  $ git config foo.bar=some-value
  error: invalid key: foo.bar=some-value

But your argument actually _is_ a syntactically valid key, because of
the dots. In a three-level key like "one.two.three", the second level
subsection is allowed to contain any character (including "=" and more
dots). So your "user.email=alt.email@alt.domain" tries to look up the
config represented by:

  [user "email=alt.email@alt"]
  domain

Which of course did not exist.

> Is this intentional?

Yes, everything is working as intended. The documentation in
git-config(1) seems to be quite poor at describing the various operating
modes, though.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug: 'git config --local user.email=<alt.email>' fails silently?
  2017-04-02  7:38 ` Jeff King
@ 2017-04-02  7:53   ` Knut Omang
  0 siblings, 0 replies; 3+ messages in thread
From: Knut Omang @ 2017-04-02  7:53 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On Sun, 2017-04-02 at 03:38 -0400, Jeff King wrote:
> On Sun, Apr 02, 2017 at 07:47:23AM +0200, Knut Omang wrote:
> 
> > From the documentation I would have expected 
> > 
> > git config --local user.email=alt.email@alt.domain
> > 
> > to create a section 
> > 
> > [user]
> > 	email=alt.email@alt.domain
> > 
> > in the local .git/config.
> 
> When it sees one argument, git-config treats that argument as a key to
> be retrieved. When given two, the second is a value to be set. E.g.:
> 
>   $ git config foo.bar
>   $ git config foo.bar some-value
>   $ git config foo.bar
>   some-value
> 
> So your command was interpreted as a request to fetch the value, which
> doesn't exist.
> 
> > Instead it returns status 1 with no error message.
> 
> Hopefully that explains the response you saw; we do not emit an error
> message when a key isn't found, which makes it easy for scripts to do
> things like:
> 
>   value=$(git config foo.bar || echo default-value)
> 
> without being unnecessarily noisy.
> 
> Usually we'd catch an error like yours and complain, because the key is
> syntactically invalid ("=" is not generally allowed in key names):
> 
>   $ git config foo.bar=some-value
>   error: invalid key: foo.bar=some-value
> 
> But your argument actually _is_ a syntactically valid key, because of
> the dots. In a three-level key like "one.two.three", the second level
> subsection is allowed to contain any character (including "=" and more
> dots). So your "user.email=alt.email@alt.domain" tries to look up the
> config represented by:
> 
>   [user "email=alt.email@alt"]
>   domain
> 
> Which of course did not exist.
> 
> > Is this intentional?
> 
> Yes, everything is working as intended. The documentation in
> git-config(1) seems to be quite poor at describing the various operating
> modes, though.

Ah - I see! 
Thanks for the quick answer and excellent explanation,
and sorry for the confusion - I should know well that config takes
the write argument after a blank.

I think I'll go and get myself another cup of coffee 
before I ask more questions anywhere...

Regards,
Knut

> 
> -Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-02  7:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-02  5:47 Bug: 'git config --local user.email=<alt.email>' fails silently? Knut Omang
2017-04-02  7:38 ` Jeff King
2017-04-02  7:53   ` Knut Omang

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).