git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Andrew Ardill <andrew.ardill@gmail.com>
Cc: "Sebastian Schuberth" <sschuberth@gmail.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>,
	"Jakub Narębski" <jnareb@gmail.com>
Subject: Re: Why does "git config" output nothing instead of the default value for unset variables?
Date: Sun, 14 Apr 2013 14:56:19 -0400	[thread overview]
Message-ID: <20130414185619.GB1621@sigill.intra.peff.net> (raw)
In-Reply-To: <CAH5451nL0cmTy+vwEsJnvX7OP1iSSgY9UMhvrrimk0zWM71YDw@mail.gmail.com>

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

  parent reply	other threads:[~2013-04-14 18:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2013-04-14 19:05     ` Sebastian Schuberth
2013-04-14 14:30 ` Jakub Narębski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130414185619.GB1621@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=andrew.ardill@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    --cc=sschuberth@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).