git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git config error message
@ 2007-11-12 15:35 Jon Smirl
  2007-11-12 22:23 ` Alex Riesen
  0 siblings, 1 reply; 14+ messages in thread
From: Jon Smirl @ 2007-11-12 15:35 UTC (permalink / raw)
  To: Git Mailing List

I'm not in a git repo, this error message is misleading.

jonsmirl@terra:~/foo$ git config remote.origin.url
http://git.digispeaker.com/projects/digispeaker-kernel.git
could not lock config file


-- 
Jon Smirl
jonsmirl@gmail.com

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

* Re: git config error message
  2007-11-12 15:35 Jon Smirl
@ 2007-11-12 22:23 ` Alex Riesen
  2007-11-12 22:24   ` Johannes Schindelin
  0 siblings, 1 reply; 14+ messages in thread
From: Alex Riesen @ 2007-11-12 22:23 UTC (permalink / raw)
  To: Jon Smirl; +Cc: Git Mailing List

Jon Smirl, Mon, Nov 12, 2007 16:35:07 +0100:
> I'm not in a git repo, this error message is misleading.
> 
> jonsmirl@terra:~/foo$ git config remote.origin.url
> http://git.digispeaker.com/projects/digispeaker-kernel.git
> could not lock config file
> 

Cygwin or any crashes in this repo lately?
If cygwin, than we probably have a file handle leak in config code.

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

* Re: git config error message
  2007-11-12 22:23 ` Alex Riesen
@ 2007-11-12 22:24   ` Johannes Schindelin
  2007-11-12 22:26     ` Alex Riesen
  0 siblings, 1 reply; 14+ messages in thread
From: Johannes Schindelin @ 2007-11-12 22:24 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Jon Smirl, Git Mailing List

Hi,

On Mon, 12 Nov 2007, Alex Riesen wrote:

> Jon Smirl, Mon, Nov 12, 2007 16:35:07 +0100:
> > I'm not in a git repo, this error message is misleading.
> > 
> > jonsmirl@terra:~/foo$ git config remote.origin.url
> > http://git.digispeaker.com/projects/digispeaker-kernel.git
> > could not lock config file
> > 
> 
> Cygwin or any crashes in this repo lately?
> If cygwin, than we probably have a file handle leak in config code.

He said that he's not in a git repo.  Thus, .git/config does not exist, 
and is not lockable, since not even .git/ exists.

Ciao,
Dscho

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

* Re: git config error message
  2007-11-12 22:24   ` Johannes Schindelin
@ 2007-11-12 22:26     ` Alex Riesen
  2007-11-12 23:09       ` Jakub Narebski
  0 siblings, 1 reply; 14+ messages in thread
From: Alex Riesen @ 2007-11-12 22:26 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Jon Smirl, Git Mailing List

Johannes Schindelin, Mon, Nov 12, 2007 23:24:54 +0100:
> Hi,
> 
> On Mon, 12 Nov 2007, Alex Riesen wrote:
> 
> > Jon Smirl, Mon, Nov 12, 2007 16:35:07 +0100:
> > > I'm not in a git repo, this error message is misleading.
> > > 
> > > jonsmirl@terra:~/foo$ git config remote.origin.url
> > > http://git.digispeaker.com/projects/digispeaker-kernel.git
> > > could not lock config file
> > > 
> > 
> > Cygwin or any crashes in this repo lately?
> > If cygwin, than we probably have a file handle leak in config code.
> 
> He said that he's not in a git repo.  Thus, .git/config does not exist, 
> and is not lockable, since not even .git/ exists.
> 

Oh.

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

* Re: git config error message
  2007-11-12 22:26     ` Alex Riesen
@ 2007-11-12 23:09       ` Jakub Narebski
  0 siblings, 0 replies; 14+ messages in thread
From: Jakub Narebski @ 2007-11-12 23:09 UTC (permalink / raw)
  To: git

Alex Riesen wrote:

> Johannes Schindelin, Mon, Nov 12, 2007 23:24:54 +0100:
>> Hi,
>> On Mon, 12 Nov 2007, Alex Riesen wrote:
>>> Jon Smirl, Mon, Nov 12, 2007 16:35:07 +0100:
>>>
>>>> I'm not in a git repo, this error message is misleading.
>>>> 
>>>> jonsmirl@terra:~/foo$ git config remote.origin.url
>>>> http://git.digispeaker.com/projects/digispeaker-kernel.git
>>>> could not lock config file
>>>> 
>>> 
>>> Cygwin or any crashes in this repo lately?
>>> If cygwin, than we probably have a file handle leak in config code.
>> 
>> He said that he's not in a git repo.  Thus, .git/config does not exist, 
>> and is not lockable, since not even .git/ exists.
>> 
> 
> Oh.

And neither does per-user config file (I triet to reproduce this error, and
forgot about ~/.gitconfig file).

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

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

* git config error message
@ 2012-10-27  8:10 Angelo Borsotti
  2012-10-27  8:25 ` Andreas Schwab
  0 siblings, 1 reply; 14+ messages in thread
From: Angelo Borsotti @ 2012-10-27  8:10 UTC (permalink / raw)
  To: git

Hello,

git config --get issues an error message when the specified value
contains a section that does not exist, but does not issue any message
when the value contains a key that does not exist while in both cases
returning a status 1. E.g.

$ git config --get xxx
error: key does not contain a section: xxx

$ git config --get xxx.yyy

Proposal: to issue an error message also when the key does not exist.

-Angelo Borsotti

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

* Re: git config error message
  2012-10-27  8:10 git config error message Angelo Borsotti
@ 2012-10-27  8:25 ` Andreas Schwab
  2012-10-27  8:32   ` Angelo Borsotti
  0 siblings, 1 reply; 14+ messages in thread
From: Andreas Schwab @ 2012-10-27  8:25 UTC (permalink / raw)
  To: Angelo Borsotti; +Cc: git

Angelo Borsotti <angelo.borsotti@gmail.com> writes:

> git config --get issues an error message when the specified value
> contains a section that does not exist, but does not issue any message
> when the value contains a key that does not exist while in both cases
> returning a status 1. E.g.
>
> $ git config --get xxx
> error: key does not contain a section: xxx
>
> $ git config --get xxx.yyy
>
> Proposal: to issue an error message also when the key does not exist.

The two cases are different: a key without a section is malformed,
whereas a nonexistent value is usually not an error (use the default
instead).

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: git config error message
  2012-10-27  8:25 ` Andreas Schwab
@ 2012-10-27  8:32   ` Angelo Borsotti
  2012-10-27  8:44     ` Andreas Schwab
  2012-10-27  8:45     ` Ben Walton
  0 siblings, 2 replies; 14+ messages in thread
From: Angelo Borsotti @ 2012-10-27  8:32 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: git

Hi Andreas,

I wrote "value", but I meant "name". The first example I made contains
a name with a nonexistent section, the second a name with a
nonexistent key.

-Angelo

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

* Re: git config error message
  2012-10-27  8:32   ` Angelo Borsotti
@ 2012-10-27  8:44     ` Andreas Schwab
  2012-10-27  8:45     ` Ben Walton
  1 sibling, 0 replies; 14+ messages in thread
From: Andreas Schwab @ 2012-10-27  8:44 UTC (permalink / raw)
  To: Angelo Borsotti; +Cc: git

Angelo Borsotti <angelo.borsotti@gmail.com> writes:

> I wrote "value", but I meant "name". The first example I made contains
> a name with a nonexistent section, the second a name with a
> nonexistent key.

And a nonexistent key is a valid key, so not an error.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: git config error message
  2012-10-27  8:32   ` Angelo Borsotti
  2012-10-27  8:44     ` Andreas Schwab
@ 2012-10-27  8:45     ` Ben Walton
  2012-10-27 10:36       ` Angelo Borsotti
  1 sibling, 1 reply; 14+ messages in thread
From: Ben Walton @ 2012-10-27  8:45 UTC (permalink / raw)
  To: Angelo Borsotti; +Cc: Andreas Schwab, git

On Sat, Oct 27, 2012 at 9:32 AM, Angelo Borsotti
<angelo.borsotti@gmail.com> wrote:

Hi Angelo,

> I wrote "value", but I meant "name". The first example I made contains
> a name with a nonexistent section, the second a name with a
> nonexistent key.

This still wouldn't be an error condition though, especially in terms
of how "git config" should treat it.  It should be up to the consumer
of the information to display, or not, any error or diagnostics that
don't result from either a bad request (your first case) or a
malformed configuration file.  This fits with the callback nature of
how the config file is parsed by builtin tools.  The exit code from
"git config" with a missing key is enough for the consumer to make
this decision.

This is just my take on it, but I think the current approach makes sense.

Thanks
-Ben
-- 
---------------------------------------------------------------------------------------------------------------------------
Take the risk of thinking for yourself.  Much more happiness,
truth, beauty and wisdom will come to you that way.

-Christopher Hitchens
---------------------------------------------------------------------------------------------------------------------------

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

* Re: git config error message
  2012-10-27  8:45     ` Ben Walton
@ 2012-10-27 10:36       ` Angelo Borsotti
  2012-10-27 13:14         ` Andreas Schwab
  0 siblings, 1 reply; 14+ messages in thread
From: Angelo Borsotti @ 2012-10-27 10:36 UTC (permalink / raw)
  To: Ben Walton; +Cc: Andreas Schwab, git

Hi Ben

> This still wouldn't be an error condition though, especially in terms
> of how "git config" should treat it.

The man page says:

   "This command will fail with non-zero status upon error."

Of course, one might claim that this does not mean the truth of the
reverse condition, i.e. that when the command returns 1 that is
necessarily an error, but I would leave that avenue of thinking to
philosophers. Besides that, it is common practice in *nix OSs to
consider a return != 0 as an error.

> It should be up to the consumer
> of the information to display, or not, any error or diagnostics that
> don't result from either a bad request (your first case) or a
> malformed configuration file.  This fits with the callback nature of
> how the config file is parsed by builtin tools.  The exit code from
> "git config" with a missing key is enough for the consumer to make
> this decision.
>

A well-behaved, user-friendly program, when detects an error tells the
user what went wrong.
How can otherwise the user tell a corrupted configuration file from a
missing key?

Of course, is is possible to provide a git-config that simply returns
0 when it has got the key and 1 when it does not, without issuing any
error message, but the current one is not like that, it is a middle
way solution.

-Angelo

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

* Re: git config error message
  2012-10-27 10:36       ` Angelo Borsotti
@ 2012-10-27 13:14         ` Andreas Schwab
  2012-10-27 14:50           ` Angelo Borsotti
  0 siblings, 1 reply; 14+ messages in thread
From: Andreas Schwab @ 2012-10-27 13:14 UTC (permalink / raw)
  To: Angelo Borsotti; +Cc: Ben Walton, git

Angelo Borsotti <angelo.borsotti@gmail.com> writes:

> Besides that, it is common practice in *nix OSs to
> consider a return != 0 as an error.

Is grep not finding a match an error?  Is cmp finding a difference an
error?  It all depends on the context.

> How can otherwise the user tell a corrupted configuration file from a
> missing key?

You cannot, as long as your configuration file is well-formed, because a
missing key is an expected condition in many cases.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: git config error message
  2012-10-27 13:14         ` Andreas Schwab
@ 2012-10-27 14:50           ` Angelo Borsotti
  2012-10-27 16:12             ` Andreas Schwab
  0 siblings, 1 reply; 14+ messages in thread
From: Angelo Borsotti @ 2012-10-27 14:50 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Ben Walton, git

Hi Andreas,

>
> Is grep not finding a match an error?  Is cmp finding a difference an
> error?  It all depends on the context.
>

Manpage of grep, exit staus:

   "Normally, the exit status is 0 if selected lines are found and 1
otherwise. But the exit status is 2 if an error occurred, ..."

cmp uses the same convention (albeit not reported in its manpage).

I am not stating that all linux commands and utilities follow exactly
the same convention, but these
two are at least consistent with themselves always returning an exit
status that has a well defined meaning. git-config returns
consistently the exit status, it only issues in certain cases messages
and in others not. A consistent solution could be for it to return 0
upon success, 1 when the section or key is absent, and 2 when the
config file does not exist or is corrupt issuing also an error
message.

-Angelo

>> How can otherwise the user tell a corrupted configuration file from a
>> missing key?
>
> You cannot, as long as your configuration file is well-formed, because a
> missing key is an expected condition in many cases.
>
> Andreas.
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."

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

* Re: git config error message
  2012-10-27 14:50           ` Angelo Borsotti
@ 2012-10-27 16:12             ` Andreas Schwab
  0 siblings, 0 replies; 14+ messages in thread
From: Andreas Schwab @ 2012-10-27 16:12 UTC (permalink / raw)
  To: Angelo Borsotti; +Cc: Ben Walton, git

Angelo Borsotti <angelo.borsotti@gmail.com> writes:

> when the section or key is absent

When the key is malformed you get an error, otherwise not.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

end of thread, other threads:[~2012-10-27 16:13 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-27  8:10 git config error message Angelo Borsotti
2012-10-27  8:25 ` Andreas Schwab
2012-10-27  8:32   ` Angelo Borsotti
2012-10-27  8:44     ` Andreas Schwab
2012-10-27  8:45     ` Ben Walton
2012-10-27 10:36       ` Angelo Borsotti
2012-10-27 13:14         ` Andreas Schwab
2012-10-27 14:50           ` Angelo Borsotti
2012-10-27 16:12             ` Andreas Schwab
  -- strict thread matches above, loose matches on Subject: below --
2007-11-12 15:35 Jon Smirl
2007-11-12 22:23 ` Alex Riesen
2007-11-12 22:24   ` Johannes Schindelin
2007-11-12 22:26     ` Alex Riesen
2007-11-12 23:09       ` Jakub Narebski

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).