git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Lars Schneider <larsxschneider@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>,
	git@vger.kernel.org, sschuberth@gmail.com,
	ramsay@ramsayjones.plus.com, sunshine@sunshineco.com,
	hvoigt@hvoigt.net, sbeller@google.com
Subject: Re: [PATCH v3 2/3] config: add 'type' to config_source struct that identifies config type
Date: Sun, 14 Feb 2016 13:26:27 +0100	[thread overview]
Message-ID: <A74A1FE2-7C03-448F-8147-BBF276322E62@gmail.com> (raw)
In-Reply-To: <xmqqio1ss4on.fsf@gitster.mtv.corp.google.com>


On 13 Feb 2016, at 22:04, Junio C Hamano <gitster@pobox.com> wrote:

> Jeff King <peff@peff.net> writes:
> 
>>> @@ -1104,6 +1106,7 @@ int git_config_from_buf(config_fn_t fn, const char *name, const char *buf,
>>> 	top.u.buf.buf = buf;
>>> 	top.u.buf.len = len;
>>> 	top.u.buf.pos = 0;
>>> +	top.type = "blob";
>>> 	top.name = name;
>>> 	top.path = NULL;
>>> 	top.die_on_error = 0;
>> 
>> This function is about reading config from a memory buffer. The only reason
>> we do so _now_ is when reading from a blob, but I think it is laying a
>> trap for somebody who wants to reuse the function later.
>> 
>> Should git_config_from_buf() take a "type" parameter, and
>> git_config_from_blob_sha1() pass in "blob"?
> 
> I think that is sensible.  I think s/from_buf/from_mem/ may also be
> sensible (it would match the naming used in the index_{fd,mem,...}
> functions in he hashing code).
OK, I will change that, too!


> 
>>> static int git_config_from_stdin(config_fn_t fn, void *data)
>>> {
>>> -	return do_config_from_file(fn, "<stdin>", NULL, stdin, data);
>>> +	return do_config_from_file(fn, NULL, NULL, stdin, data);
>>> }
>> 
>> Likewise here, we make assumptions in do_config_from_file() about what
>> the NULL path means. I think this is less likely to be a problem than
>> the other case, but it seems like it would be cleaner for "file" or
>> "stdin" to come from the caller, which knows for sure what we are doing.
> 
> Makes sense.
> 
>> Similarly, I think git_config_from_stdin() can simply pass in an empty
>> name rather than NULL to avoid do_config_from_file() having to fix it
>> up.
> 
> This too.
> 
>>> +test_expect_success 'invalid stdin config' '
>>> +	echo "fatal: bad config line 1 in stdin " >expect &&
>>> +	echo "[broken" | test_must_fail git config --list --file - >output 2>&1 &&
>>> +	test_cmp expect output
>>> +'
>> 
>> The original would have been "bad config file line 1 in <stdin>"; I
>> think this is an improvement to drop the "file" here.
>> 
>> -Peff

Thanks,
Lars

  reply	other threads:[~2016-02-14 12:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-13 14:24 [PATCH v3 0/3] config: add '--sources' option to print the source of a config value larsxschneider
2016-02-13 14:24 ` [PATCH v3 1/3] git-config.txt: describe '--includes' default behavior larsxschneider
2016-02-13 17:17   ` Jeff King
2016-02-13 21:00     ` Junio C Hamano
2016-02-14  0:34       ` Jeff King
2016-02-14 12:17     ` Lars Schneider
2016-02-14 16:05       ` Jeff King
2016-02-13 14:24 ` [PATCH v3 2/3] config: add 'type' to config_source struct that identifies config type larsxschneider
2016-02-13 17:24   ` Jeff King
2016-02-13 21:04     ` Junio C Hamano
2016-02-14 12:26       ` Lars Schneider [this message]
2016-02-14 12:24     ` Lars Schneider
2016-02-14 16:07       ` Jeff King
2016-02-13 14:24 ` [PATCH v3 3/3] config: add '--show-origin' option to print the origin of a config value larsxschneider
2016-02-13 17:44   ` Jeff King
2016-02-13 18:04     ` Jeff King
2016-02-13 18:15       ` Jeff King
2016-02-15  9:41         ` Lars Schneider
2016-02-14 12:48     ` Lars Schneider
2016-02-14 16:18       ` Jeff King
2016-02-15  7:53         ` Johannes Schindelin
2016-02-13 14:43 ` [PATCH v3 0/3] config: add '--sources' option to print the source " Mike Rappazzo
2016-02-13 17:26   ` Sebastian Schuberth
2016-02-13 18:19   ` Jeff King
2016-02-13 21:05     ` Junio C Hamano

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=A74A1FE2-7C03-448F-8147-BBF276322E62@gmail.com \
    --to=larsxschneider@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hvoigt@hvoigt.net \
    --cc=peff@peff.net \
    --cc=ramsay@ramsayjones.plus.com \
    --cc=sbeller@google.com \
    --cc=sschuberth@gmail.com \
    --cc=sunshine@sunshineco.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).