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

Re: Bug: 'git config --local user.email=<alt.email>' fails silently?

From
Jeff King <peff@peff.net>
Date
Apr 2, 2017, 07:38 UTC
Message-ID
<20170402073823.tudnfftbxaa6jdo5@sigill.intra.peff.net>
In-Reply-To
<1491112043.5830.11.camel@oracle.com>
On Sun, Apr 02, 2017 at 07:47:23AM +0200, Knut Omang wrote:
Show 10 quoted lines
> 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
Previous: Knut OmangNext: Knut Omang
Message 2 of 3 in “Bug: 'git config --local user.email=<alt.email>' fails silently?”
  1. Knut OmangApr 2, 2017
  2. Jeff KingApr 2, 2017
  3. Knut OmangApr 2, 2017

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.