{"thread":{"id":"31955","subject":"git config error message","startedAt":"2012-10-27T08:10:04Z","lastAt":"2012-10-27T16:12:45Z","messageCount":9,"participants":["Angelo Borsotti","Andreas Schwab","Ben Walton"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"201998","messageId":"CAB9Jk9AQkSiv=F8NeYs+uspR5f4CeJS5L-hwZUXdq7dts1W5ng@mail.gmail.com","threadId":"31955","inReplyTo":null,"subject":"git config error message","fromName":"Angelo Borsotti","fromEmail":"angelo.borsotti@gmail.com","sentAt":"2012-10-27T08:10:04Z","receivedAt":"2012-10-27T08:10:04Z","isPatch":false,"sender":{"key":"angelo.borsotti@gmail.com","avatar":null},"body":"Hello,\n\ngit config --get issues an error message when the specified value\ncontains a section that does not exist, but does not issue any message\nwhen the value contains a key that does not exist while in both cases\nreturning a status 1. E.g.\n\n$ git config --get xxx\nerror: key does not contain a section: xxx\n\n$ git config --get xxx.yyy\n\nProposal: to issue an error message also when the key does not exist.\n\n-Angelo Borsotti\n"},{"id":"201999","messageId":"m2bofo9v93.fsf@linux-m68k.org","threadId":"31955","inReplyTo":"CAB9Jk9AQkSiv=F8NeYs+uspR5f4CeJS5L-hwZUXdq7dts1W5ng@mail.gmail.com","subject":"Re: git config error message","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-10-27T08:25:44Z","receivedAt":"2012-10-27T08:25:44Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Angelo Borsotti <angelo.borsotti@gmail.com> writes:\n\n> git config --get issues an error message when the specified value\n> contains a section that does not exist, but does not issue any message\n> when the value contains a key that does not exist while in both cases\n> returning a status 1. E.g.\n>\n> $ git config --get xxx\n> error: key does not contain a section: xxx\n>\n> $ git config --get xxx.yyy\n>\n> Proposal: to issue an error message also when the key does not exist.\n\nThe two cases are different: a key without a section is malformed,\nwhereas a nonexistent value is usually not an error (use the default\ninstead).\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"202000","messageId":"CAB9Jk9CONVSZvBUgnZHiniwPHHvcap8Wyjyw-sCHaSokDoNRWA@mail.gmail.com","threadId":"31955","inReplyTo":"m2bofo9v93.fsf@linux-m68k.org","subject":"Re: git config error message","fromName":"Angelo Borsotti","fromEmail":"angelo.borsotti@gmail.com","sentAt":"2012-10-27T08:32:48Z","receivedAt":"2012-10-27T08:32:48Z","isPatch":false,"sender":{"key":"angelo.borsotti@gmail.com","avatar":null},"body":"Hi Andreas,\n\nI wrote \"value\", but I meant \"name\". The first example I made contains\na name with a nonexistent section, the second a name with a\nnonexistent key.\n\n-Angelo\n"},{"id":"202001","messageId":"m27gqc9udc.fsf@linux-m68k.org","threadId":"31955","inReplyTo":"CAB9Jk9CONVSZvBUgnZHiniwPHHvcap8Wyjyw-sCHaSokDoNRWA@mail.gmail.com","subject":"Re: git config error message","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-10-27T08:44:47Z","receivedAt":"2012-10-27T08:44:47Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Angelo Borsotti <angelo.borsotti@gmail.com> writes:\n\n> I wrote \"value\", but I meant \"name\". The first example I made contains\n> a name with a nonexistent section, the second a name with a\n> nonexistent key.\n\nAnd a nonexistent key is a valid key, so not an error.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"202003","messageId":"CAP30j15pUwX9sD3FXAfroxFK9paHmb1eAg+M5YAHT4aB22DBEw@mail.gmail.com","threadId":"31955","inReplyTo":"CAB9Jk9CONVSZvBUgnZHiniwPHHvcap8Wyjyw-sCHaSokDoNRWA@mail.gmail.com","subject":"Re: git config error message","fromName":"Ben Walton","fromEmail":"bdwalton@gmail.com","sentAt":"2012-10-27T08:45:24Z","receivedAt":"2012-10-27T08:45:24Z","isPatch":false,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"On Sat, Oct 27, 2012 at 9:32 AM, Angelo Borsotti\n<angelo.borsotti@gmail.com> wrote:\n\nHi Angelo,\n\n> I wrote \"value\", but I meant \"name\". The first example I made contains\n> a name with a nonexistent section, the second a name with a\n> nonexistent key.\n\nThis still wouldn't be an error condition though, especially in terms\nof how \"git config\" should treat it.  It should be up to the consumer\nof the information to display, or not, any error or diagnostics that\ndon't result from either a bad request (your first case) or a\nmalformed configuration file.  This fits with the callback nature of\nhow the config file is parsed by builtin tools.  The exit code from\n\"git config\" with a missing key is enough for the consumer to make\nthis decision.\n\nThis is just my take on it, but I think the current approach makes sense.\n\nThanks\n-Ben\n-- \n---------------------------------------------------------------------------------------------------------------------------\nTake the risk of thinking for yourself.  Much more happiness,\ntruth, beauty and wisdom will come to you that way.\n\n-Christopher Hitchens\n---------------------------------------------------------------------------------------------------------------------------\n"},{"id":"202004","messageId":"CAB9Jk9COSZOske5xzgnE=1oHe7qiwwOzHYE6pJkuZ0sZyZYhng@mail.gmail.com","threadId":"31955","inReplyTo":"CAP30j15pUwX9sD3FXAfroxFK9paHmb1eAg+M5YAHT4aB22DBEw@mail.gmail.com","subject":"Re: git config error message","fromName":"Angelo Borsotti","fromEmail":"angelo.borsotti@gmail.com","sentAt":"2012-10-27T10:36:36Z","receivedAt":"2012-10-27T10:36:36Z","isPatch":false,"sender":{"key":"angelo.borsotti@gmail.com","avatar":null},"body":"Hi Ben\n\n> This still wouldn't be an error condition though, especially in terms\n> of how \"git config\" should treat it.\n\nThe man page says:\n\n   \"This command will fail with non-zero status upon error.\"\n\nOf course, one might claim that this does not mean the truth of the\nreverse condition, i.e. that when the command returns 1 that is\nnecessarily an error, but I would leave that avenue of thinking to\nphilosophers. Besides that, it is common practice in *nix OSs to\nconsider a return != 0 as an error.\n\n> It should be up to the consumer\n> of the information to display, or not, any error or diagnostics that\n> don't result from either a bad request (your first case) or a\n> malformed configuration file.  This fits with the callback nature of\n> how the config file is parsed by builtin tools.  The exit code from\n> \"git config\" with a missing key is enough for the consumer to make\n> this decision.\n>\n\nA well-behaved, user-friendly program, when detects an error tells the\nuser what went wrong.\nHow can otherwise the user tell a corrupted configuration file from a\nmissing key?\n\nOf course, is is possible to provide a git-config that simply returns\n0 when it has got the key and 1 when it does not, without issuing any\nerror message, but the current one is not like that, it is a middle\nway solution.\n\n-Angelo\n"},{"id":"202007","messageId":"m2d3049hvs.fsf@igel.home","threadId":"31955","inReplyTo":"CAB9Jk9COSZOske5xzgnE=1oHe7qiwwOzHYE6pJkuZ0sZyZYhng@mail.gmail.com","subject":"Re: git config error message","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-10-27T13:14:31Z","receivedAt":"2012-10-27T13:14:31Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Angelo Borsotti <angelo.borsotti@gmail.com> writes:\n\n> Besides that, it is common practice in *nix OSs to\n> consider a return != 0 as an error.\n\nIs grep not finding a match an error?  Is cmp finding a difference an\nerror?  It all depends on the context.\n\n> How can otherwise the user tell a corrupted configuration file from a\n> missing key?\n\nYou cannot, as long as your configuration file is well-formed, because a\nmissing key is an expected condition in many cases.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"202010","messageId":"CAB9Jk9A-uXXXKCBKvxyDN6QQx1b0zqemg7UbeRMcWeY7gi4MRQ@mail.gmail.com","threadId":"31955","inReplyTo":"m2d3049hvs.fsf@igel.home","subject":"Re: git config error message","fromName":"Angelo Borsotti","fromEmail":"angelo.borsotti@gmail.com","sentAt":"2012-10-27T14:50:32Z","receivedAt":"2012-10-27T14:50:32Z","isPatch":false,"sender":{"key":"angelo.borsotti@gmail.com","avatar":null},"body":"Hi Andreas,\n\n>\n> Is grep not finding a match an error?  Is cmp finding a difference an\n> error?  It all depends on the context.\n>\n\nManpage of grep, exit staus:\n\n   \"Normally, the exit status is 0 if selected lines are found and 1\notherwise. But the exit status is 2 if an error occurred, ...\"\n\ncmp uses the same convention (albeit not reported in its manpage).\n\nI am not stating that all linux commands and utilities follow exactly\nthe same convention, but these\ntwo are at least consistent with themselves always returning an exit\nstatus that has a well defined meaning. git-config returns\nconsistently the exit status, it only issues in certain cases messages\nand in others not. A consistent solution could be for it to return 0\nupon success, 1 when the section or key is absent, and 2 when the\nconfig file does not exist or is corrupt issuing also an error\nmessage.\n\n-Angelo\n\n>> How can otherwise the user tell a corrupted configuration file from a\n>> missing key?\n>\n> You cannot, as long as your configuration file is well-formed, because a\n> missing key is an expected condition in many cases.\n>\n> Andreas.\n>\n> --\n> Andreas Schwab, schwab@linux-m68k.org\n> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n> \"And now for something completely different.\"\n"},{"id":"202011","messageId":"m2r4oj99mq.fsf@igel.home","threadId":"31955","inReplyTo":"CAB9Jk9A-uXXXKCBKvxyDN6QQx1b0zqemg7UbeRMcWeY7gi4MRQ@mail.gmail.com","subject":"Re: git config error message","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-10-27T16:12:45Z","receivedAt":"2012-10-27T16:12:45Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Angelo Borsotti <angelo.borsotti@gmail.com> writes:\n\n> when the section or key is absent\n\nWhen the key is malformed you get an error, otherwise not.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"}]}