From: Jeff King <peff@peff.net>
To: Sebastian Schuberth <sschuberth@gmail.com>
Cc: larsxschneider@gmail.com, git@vger.kernel.org
Subject: Re: [PATCH v1] config: add '--sources' option to print the source of a config value
Date: Fri, 5 Feb 2016 08:58:55 -0500 [thread overview]
Message-ID: <20160205135855.GA19154@sigill.intra.peff.net> (raw)
In-Reply-To: <56B48803.9080909@gmail.com>
On Fri, Feb 05, 2016 at 12:31:15PM +0100, Sebastian Schuberth wrote:
> >I'm not sure returning here is the best idea. We won't have a config
> >filename if we are reading from "-c", but if we return early from this
> >function, it parses differently than every other line. E.g., with your
> >patch, if I do:
> >
> > git config -c foo.bar=true config --sources --list
> >
> >I'll get:
> >
> > /home/peff/.gitconfig <tab> user.name=Jeff King
> > /home/peff/.gitconfig <tab> user.email=peff@peff.net
> > ...etc...
> > foo.bar=true
> >
> >If somebody is parsing this as a tab-delimited list, then instead of the
> >source field for that line being empty, it is missing (and it looks like
> >"foo.bar=true" is the source file). I think it would be more friendly to
> >consumers of the output to have a blank (i.e., set "fn" to the empty
> >string and continue in the function).
>
> Or to come up with a special string to denote config values specified on the
> command line. Maybe somehting like
>
> <command line> <tab> foo.bar=true
>
> I acknowledge that "<command line>" would be a valid filename on some
> filesystems, but I think the risk is rather low that someone would actually
> be using that name for a Git config file.
Yeah, I agree it's unlikely. And the output is already ambiguous, as the
first field could be a blob (though I guess the caller knows if they
passed "--blob" or not). If we really wanted an unambiguous output, we
could have something like "file:...", "blob:...", etc. But that's a bit
less readable for humans, and I don't think solves any real-world
problems.
So I think it would be OK to use "<command line>" here, as long as the
token is documented.
Are there any other reasons why current_config_filename() would return
NULL, besides command-line config? I don't think so. It looks like we
can read config from stdin, but we use the token "<stdin>" there for the
name field (another ambiguity!).
-Peff
next prev parent reply other threads:[~2016-02-05 13:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 8:42 [PATCH v1] config: add '--sources' option to print the source of a config value larsxschneider
2016-02-05 11:13 ` Sebastian Schuberth
2016-02-05 11:22 ` Jeff King
2016-02-07 19:28 ` Lars Schneider
2016-02-08 11:22 ` Sebastian Schuberth
2016-02-08 12:11 ` Jeff King
2016-02-05 11:20 ` Jeff King
2016-02-05 11:31 ` Sebastian Schuberth
2016-02-05 13:58 ` Jeff King [this message]
2016-02-07 19:44 ` Lars Schneider
2016-02-08 12:12 ` Jeff King
2016-02-08 11:25 ` Sebastian Schuberth
2016-02-08 12:08 ` Jeff King
2016-02-07 18:26 ` Lars Schneider
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160205135855.GA19154@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=larsxschneider@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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).