{"thread":{"id":"33505","subject":"Why does \"git config\" output nothing instead of the default value for unset variables?","startedAt":"2013-04-14T12:34:12Z","lastAt":"2013-04-14T19:05:21Z","messageCount":7,"participants":["Sebastian Schuberth","Andrew Ardill","Jakub Narębski","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"214169","messageId":"kke7o1$oo$1@ger.gmane.org","threadId":"33505","inReplyTo":null,"subject":"Why does \"git config\" output nothing instead of the default value for unset variables?","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2013-04-14T12:34:12Z","receivedAt":"2013-04-14T12:34:12Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"Hi,\n\nI'm just wondering why it was decided to work like this. IMHO it's quite \ninconvenient that git config outputs nothing for any unset (but known) \nvariable. Usually when I query a variable I'm not so much interested in \nwhether it is at all (explicitly) set to some value or not, but what \nvalue is currently in use. With that in mind, it would make much more \nsense for git config to print the implicit default value instead of \nnothing if a known variable is unset. For unknown / custom variables it \nstill could display nothing, which also gives a nice way to check \nwhether a given variable name is known to Git or not.\n\n-- \nSebastian Schuberth\n"},{"id":"214171","messageId":"CAH5451nL0cmTy+vwEsJnvX7OP1iSSgY9UMhvrrimk0zWM71YDw@mail.gmail.com","threadId":"33505","inReplyTo":"kke7o1$oo$1@ger.gmane.org","subject":"Re: Why does \"git config\" output nothing instead of the default value for unset variables?","fromName":"Andrew Ardill","fromEmail":"andrew.ardill@gmail.com","sentAt":"2013-04-14T12:47:31Z","receivedAt":"2013-04-14T12:47:31Z","isPatch":false,"sender":{"key":"andrew.ardill@gmail.com","avatar":"https://gravatar.com/avatar/da14cb7c091dd44dc6c63a4d3361b149acaf25226dc78eb4131a17b93d9b0993?d=mp&s=160"},"body":"On 14 April 2013 22:34, Sebastian Schuberth <sschuberth@gmail.com> wrote:\n> Usually when I query a variable I'm not so much interested in whether it is at all (explicitly) set to some value or not, but what value is currently in use.\n\nWith your change in place, how do you know if the config item has been\nexplicitly set in your system?\n\nThe closest thing I can see for doing this is git config --list, but\nperhaps there should be a flag to check if a config item is set?\n\nMore to the point, I can easily imagine many scripts relying on git\nconfig returning a value to indicate that a config item has been set.\nYour proposed change would break all those. For that reason, it might\nbe nicer to introduce a flag that returns the config if it is set or\nthe default otherwise. Something like git config --value perhaps.\n\nRegards,\n\nAndrew Ardill\n"},{"id":"214191","messageId":"CAHGBnuO2d9Wkez4sLLKp3Ei0vkAJBjJp1+m+Lsu3ozaKPQD29A@mail.gmail.com","threadId":"33505","inReplyTo":"CAH5451nL0cmTy+vwEsJnvX7OP1iSSgY9UMhvrrimk0zWM71YDw@mail.gmail.com","subject":"Re: Why does \"git config\" output nothing instead of the default value for unset variables?","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2013-04-14T12:56:22Z","receivedAt":"2013-04-14T12:56:22Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On Sun, Apr 14, 2013 at 2:47 PM, Andrew Ardill <andrew.ardill@gmail.com> wrote:\n\n> On 14 April 2013 22:34, Sebastian Schuberth <sschuberth@gmail.com> wrote:\n>> Usually when I query a variable I'm not so much interested in whether it is at all (explicitly) set to some value or not, but what value is currently in use.\n>\n> With your change in place, how do you know if the config item has been\n> explicitly set in your system?\n\nWell, this could be done several ways. Maybe output the variable value\nin all upper case if it's the implicit / built-in default, and in all\nlower case if it has been explicitly set somewhere.\n\n> The closest thing I can see for doing this is git config --list, but\n> perhaps there should be a flag to check if a config item is set?\n\nYet more command line options? Well, there's probably no way around\nthat in order to maintain backward compatibility.\n\n> More to the point, I can easily imagine many scripts relying on git\n> config returning a value to indicate that a config item has been set.\n> Your proposed change would break all those. For that reason, it might\n> be nicer to introduce a flag that returns the config if it is set or\n> the default otherwise. Something like git config --value perhaps.\n\nRight.\n\n-- \nSebastian Schuberth\n"},{"id":"214207","messageId":"CAH5451=GsvVLX+08agpWgggTdYsgpD8H-JHxGOgThC=D=GObhw@mail.gmail.com","threadId":"33505","inReplyTo":"CAHGBnuO2d9Wkez4sLLKp3Ei0vkAJBjJp1+m+Lsu3ozaKPQD29A@mail.gmail.com","subject":"Re: Why does \"git config\" output nothing instead of the default value for unset variables?","fromName":"Andrew Ardill","fromEmail":"andrew.ardill@gmail.com","sentAt":"2013-04-14T13:03:36Z","receivedAt":"2013-04-14T13:03:36Z","isPatch":false,"sender":{"key":"andrew.ardill@gmail.com","avatar":"https://gravatar.com/avatar/da14cb7c091dd44dc6c63a4d3361b149acaf25226dc78eb4131a17b93d9b0993?d=mp&s=160"},"body":"On 14 April 2013 22:56, Sebastian Schuberth <sschuberth@gmail.com> wrote:\n>> The closest thing I can see for doing this is git config --list, but\n>> perhaps there should be a flag to check if a config item is set?\n>\n> Yet more command line options? Well, there's probably no way around\n> that in order to maintain backward compatibility.\n\n'--list' already exists; it shows all defined options. With your\nchange in place (and no others) then the only (documented) way to know\nif something was configured would be by looking at git config --list.\n\nChanging the default behaviour is probably too big a breaking change,\nbut a flag to change the behaviour might be nice. Then again, there\nmay be away to do what you want already :-)\n\nRegards,\n\nAndrew Ardill\n"},{"id":"214212","messageId":"516ABD68.5090501@gmail.com","threadId":"33505","inReplyTo":"kke7o1$oo$1@ger.gmane.org","subject":"Re: Why does \"git config\" output nothing instead of the default value for unset variables?","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2013-04-14T14:30:00Z","receivedAt":"2013-04-14T14:30:00Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Sebastian Schuberth wrote:\n> Hi,\n> \n> I'm just wondering why it was decided to work like this. IMHO it's quite\n> inconvenient that git config outputs nothing for any unset (but known)\n> variable. Usually when I query a variable I'm not so much interested in\n> whether it is at all (explicitly) set to some value or not, but what\n> value is currently in use. With that in mind, it would make much more\n> sense for git config to print the implicit default value instead of\n> nothing if a known variable is unset. For unknown / custom variables it\n> still could display nothing, which also gives a nice way to check\n> whether a given variable name is known to Git or not.\n\nI think git-config was meant to be git agnostic (and therefore usable\noutside git, and for files other that git config files).\n\nIt would be better to add required functionality to git-var, IMHO.\n\n-- \nJakub Narębski\n"},{"id":"214222","messageId":"20130414185619.GB1621@sigill.intra.peff.net","threadId":"33505","inReplyTo":"CAH5451nL0cmTy+vwEsJnvX7OP1iSSgY9UMhvrrimk0zWM71YDw@mail.gmail.com","subject":"Re: Why does \"git config\" output nothing instead of the default value for unset variables?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-04-14T18:56:19Z","receivedAt":"2013-04-14T18:56:19Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Apr 14, 2013 at 10:47:31PM +1000, Andrew Ardill wrote:\n\n> More to the point, I can easily imagine many scripts relying on git\n> config returning a value to indicate that a config item has been set.\n> Your proposed change would break all those. For that reason, it might\n> be nicer to introduce a flag that returns the config if it is set or\n> the default otherwise. Something like git config --value perhaps.\n\nThe expected output is certainly a problem, but the issue is more\nfundamental than that: git-config does not even _know_ what the default\nis for any given option.\n\nIt is assumed that the caller knows what to do with an unset value. And\nthis is nothing to do with git-config; the internal C code works the\nsame way. The actual defaults are not even necessarily expressible\nthrough the config. E.g., I know that http.receivepack considers \"unset\"\nto be distinct either \"true\" or \"false\", but setting it can yield only\none of those latter two values. I'm sure there are others, too (I just\nhappened to notice that one this week).\n\nI could certainly see an argument that the world would be a better place\nif the code had a big table of options and their descriptions, possible\nvalues, and defaults, and if we used that to generate documentation as\nwell as validate input. But nobody has gone to the trouble to construct\nthat table and convert all of the callers. And as Jakub mentioned, such\na central table can do nothing for external programs that store their\nconfig alongside git's.\n\nSo I think the desire that is expressed in this thread is reasonable,\nbut I don't see it happening anytime soon. I'd love to be proved wrong\nby somebody converting the whole system, of course. :)\n\nI'd also be fine with a \"git config --get-$TYPE $OPTION $DEFAULT\" mode;\nthe \"--get-color\" option already works like this. But the caller has\nto provide the \"$DEFAULT\", since git-config does not know it. So I\nsuspect it defeats the purpose of the original request.\n\n-Peff\n"},{"id":"214225","messageId":"CAHGBnuOJFVahoUwcF6dZZUEmDtKU_zvWsKtTwufN7RqeNxkZ=w@mail.gmail.com","threadId":"33505","inReplyTo":"20130414185619.GB1621@sigill.intra.peff.net","subject":"Re: Why does \"git config\" output nothing instead of the default value for unset variables?","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2013-04-14T19:05:21Z","receivedAt":"2013-04-14T19:05:21Z","isPatch":false,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"On Sun, Apr 14, 2013 at 8:56 PM, Jeff King <peff@peff.net> wrote:\n\n>> More to the point, I can easily imagine many scripts relying on git\n>> config returning a value to indicate that a config item has been set.\n>> Your proposed change would break all those. For that reason, it might\n>> be nicer to introduce a flag that returns the config if it is set or\n>> the default otherwise. Something like git config --value perhaps.\n>\n> The expected output is certainly a problem, but the issue is more\n> fundamental than that: git-config does not even _know_ what the default\n> is for any given option.\n\nThanks for the explanation, I feared something like that. I.e. that\ngit config does not even know any of the options or values it manages,\nbut just is a \"dumb\" front-end to writing / reading whatever you pass\nit to / from a file.\n\n-- \nSebastian Schuberth\n"}]}