* Why does "git config" output nothing instead of the default value for unset variables?
@ 2013-04-14 12:34 Sebastian Schuberth
2013-04-14 12:47 ` Andrew Ardill
2013-04-14 14:30 ` Jakub Narębski
0 siblings, 2 replies; 7+ messages in thread
From: Sebastian Schuberth @ 2013-04-14 12:34 UTC (permalink / raw)
To: git
Hi,
I'm just wondering why it was decided to work like this. IMHO it's quite
inconvenient that git config outputs nothing for any unset (but known)
variable. 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. With that in mind, it would make much more
sense for git config to print the implicit default value instead of
nothing if a known variable is unset. For unknown / custom variables it
still could display nothing, which also gives a nice way to check
whether a given variable name is known to Git or not.
--
Sebastian Schuberth
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does "git config" output nothing instead of the default value for unset variables?
2013-04-14 12:34 Why does "git config" output nothing instead of the default value for unset variables? Sebastian Schuberth
@ 2013-04-14 12:47 ` Andrew Ardill
2013-04-14 12:56 ` Sebastian Schuberth
2013-04-14 18:56 ` Jeff King
2013-04-14 14:30 ` Jakub Narębski
1 sibling, 2 replies; 7+ messages in thread
From: Andrew Ardill @ 2013-04-14 12:47 UTC (permalink / raw)
To: Sebastian Schuberth; +Cc: git@vger.kernel.org
On 14 April 2013 22:34, Sebastian Schuberth <sschuberth@gmail.com> wrote:
> 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.
With your change in place, how do you know if the config item has been
explicitly set in your system?
The closest thing I can see for doing this is git config --list, but
perhaps there should be a flag to check if a config item is set?
More to the point, I can easily imagine many scripts relying on git
config returning a value to indicate that a config item has been set.
Your proposed change would break all those. For that reason, it might
be nicer to introduce a flag that returns the config if it is set or
the default otherwise. Something like git config --value perhaps.
Regards,
Andrew Ardill
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does "git config" output nothing instead of the default value for unset variables?
2013-04-14 12:47 ` Andrew Ardill
@ 2013-04-14 12:56 ` Sebastian Schuberth
2013-04-14 13:03 ` Andrew Ardill
2013-04-14 18:56 ` Jeff King
1 sibling, 1 reply; 7+ messages in thread
From: Sebastian Schuberth @ 2013-04-14 12:56 UTC (permalink / raw)
To: Andrew Ardill; +Cc: git@vger.kernel.org
On Sun, Apr 14, 2013 at 2:47 PM, Andrew Ardill <andrew.ardill@gmail.com> wrote:
> On 14 April 2013 22:34, Sebastian Schuberth <sschuberth@gmail.com> wrote:
>> 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.
>
> With your change in place, how do you know if the config item has been
> explicitly set in your system?
Well, this could be done several ways. Maybe output the variable value
in all upper case if it's the implicit / built-in default, and in all
lower case if it has been explicitly set somewhere.
> The closest thing I can see for doing this is git config --list, but
> perhaps there should be a flag to check if a config item is set?
Yet more command line options? Well, there's probably no way around
that in order to maintain backward compatibility.
> More to the point, I can easily imagine many scripts relying on git
> config returning a value to indicate that a config item has been set.
> Your proposed change would break all those. For that reason, it might
> be nicer to introduce a flag that returns the config if it is set or
> the default otherwise. Something like git config --value perhaps.
Right.
--
Sebastian Schuberth
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does "git config" output nothing instead of the default value for unset variables?
2013-04-14 12:56 ` Sebastian Schuberth
@ 2013-04-14 13:03 ` Andrew Ardill
0 siblings, 0 replies; 7+ messages in thread
From: Andrew Ardill @ 2013-04-14 13:03 UTC (permalink / raw)
To: Sebastian Schuberth; +Cc: git@vger.kernel.org
On 14 April 2013 22:56, Sebastian Schuberth <sschuberth@gmail.com> wrote:
>> The closest thing I can see for doing this is git config --list, but
>> perhaps there should be a flag to check if a config item is set?
>
> Yet more command line options? Well, there's probably no way around
> that in order to maintain backward compatibility.
'--list' already exists; it shows all defined options. With your
change in place (and no others) then the only (documented) way to know
if something was configured would be by looking at git config --list.
Changing the default behaviour is probably too big a breaking change,
but a flag to change the behaviour might be nice. Then again, there
may be away to do what you want already :-)
Regards,
Andrew Ardill
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does "git config" output nothing instead of the default value for unset variables?
2013-04-14 12:34 Why does "git config" output nothing instead of the default value for unset variables? Sebastian Schuberth
2013-04-14 12:47 ` Andrew Ardill
@ 2013-04-14 14:30 ` Jakub Narębski
1 sibling, 0 replies; 7+ messages in thread
From: Jakub Narębski @ 2013-04-14 14:30 UTC (permalink / raw)
To: Sebastian Schuberth; +Cc: git
Sebastian Schuberth wrote:
> Hi,
>
> I'm just wondering why it was decided to work like this. IMHO it's quite
> inconvenient that git config outputs nothing for any unset (but known)
> variable. 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. With that in mind, it would make much more
> sense for git config to print the implicit default value instead of
> nothing if a known variable is unset. For unknown / custom variables it
> still could display nothing, which also gives a nice way to check
> whether a given variable name is known to Git or not.
I think git-config was meant to be git agnostic (and therefore usable
outside git, and for files other that git config files).
It would be better to add required functionality to git-var, IMHO.
--
Jakub Narębski
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does "git config" output nothing instead of the default value for unset variables?
2013-04-14 12:47 ` Andrew Ardill
2013-04-14 12:56 ` Sebastian Schuberth
@ 2013-04-14 18:56 ` Jeff King
2013-04-14 19:05 ` Sebastian Schuberth
1 sibling, 1 reply; 7+ messages in thread
From: Jeff King @ 2013-04-14 18:56 UTC (permalink / raw)
To: Andrew Ardill
Cc: Sebastian Schuberth, git@vger.kernel.org, Jakub Narębski
On Sun, Apr 14, 2013 at 10:47:31PM +1000, Andrew Ardill wrote:
> More to the point, I can easily imagine many scripts relying on git
> config returning a value to indicate that a config item has been set.
> Your proposed change would break all those. For that reason, it might
> be nicer to introduce a flag that returns the config if it is set or
> the default otherwise. Something like git config --value perhaps.
The expected output is certainly a problem, but the issue is more
fundamental than that: git-config does not even _know_ what the default
is for any given option.
It is assumed that the caller knows what to do with an unset value. And
this is nothing to do with git-config; the internal C code works the
same way. The actual defaults are not even necessarily expressible
through the config. E.g., I know that http.receivepack considers "unset"
to be distinct either "true" or "false", but setting it can yield only
one of those latter two values. I'm sure there are others, too (I just
happened to notice that one this week).
I could certainly see an argument that the world would be a better place
if the code had a big table of options and their descriptions, possible
values, and defaults, and if we used that to generate documentation as
well as validate input. But nobody has gone to the trouble to construct
that table and convert all of the callers. And as Jakub mentioned, such
a central table can do nothing for external programs that store their
config alongside git's.
So I think the desire that is expressed in this thread is reasonable,
but I don't see it happening anytime soon. I'd love to be proved wrong
by somebody converting the whole system, of course. :)
I'd also be fine with a "git config --get-$TYPE $OPTION $DEFAULT" mode;
the "--get-color" option already works like this. But the caller has
to provide the "$DEFAULT", since git-config does not know it. So I
suspect it defeats the purpose of the original request.
-Peff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Why does "git config" output nothing instead of the default value for unset variables?
2013-04-14 18:56 ` Jeff King
@ 2013-04-14 19:05 ` Sebastian Schuberth
0 siblings, 0 replies; 7+ messages in thread
From: Sebastian Schuberth @ 2013-04-14 19:05 UTC (permalink / raw)
To: Jeff King; +Cc: Andrew Ardill, git@vger.kernel.org, Jakub Narębski
On Sun, Apr 14, 2013 at 8:56 PM, Jeff King <peff@peff.net> wrote:
>> More to the point, I can easily imagine many scripts relying on git
>> config returning a value to indicate that a config item has been set.
>> Your proposed change would break all those. For that reason, it might
>> be nicer to introduce a flag that returns the config if it is set or
>> the default otherwise. Something like git config --value perhaps.
>
> The expected output is certainly a problem, but the issue is more
> fundamental than that: git-config does not even _know_ what the default
> is for any given option.
Thanks for the explanation, I feared something like that. I.e. that
git config does not even know any of the options or values it manages,
but just is a "dumb" front-end to writing / reading whatever you pass
it to / from a file.
--
Sebastian Schuberth
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-04-14 19:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-14 12:34 Why does "git config" output nothing instead of the default value for unset variables? Sebastian Schuberth
2013-04-14 12:47 ` Andrew Ardill
2013-04-14 12:56 ` Sebastian Schuberth
2013-04-14 13:03 ` Andrew Ardill
2013-04-14 18:56 ` Jeff King
2013-04-14 19:05 ` Sebastian Schuberth
2013-04-14 14:30 ` Jakub Narębski
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).