Re: [PATCH v8 2/2] test-config: add tests for the config_set API
- From
Tanay Abhra <tanayabh@gmail.com>
- Date
- Jul 15, 2014, 11:10 UTC
- Message-ID
- <loom.20140715T125714-160@post.gmane.org>
- In-Reply-To
- <xmqq8unz4v4c.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster <at> pobox.com> writes:
Show 33 quoted lines
>
> Tanay Abhra <tanayabh <at> gmail.com> writes:
>
> > diff --git a/test-config.c b/test-config.c
> > new file mode 100644
> > index 0000000..dc313c2
> > --- /dev/null
> > +++ b/test-config.c
> > <at> <at> -0,0 +1,125 <at> <at>
> > +
> > +
> > +int main(int argc, char **argv)
> > +{
> > + int i, val;
> > + const char *v;
> > + const struct string_list *strptr;
> > + struct config_set cs;
> > + git_configset_init(&cs);
> > +
> > + if (argc < 2) {
> > + fprintf(stderr, "Please, provide a command name on the command-line\n");
> > + return 1;
> > + } else if (argc == 3 && !strcmp(argv[1], "get_value")) {
> > + if (!git_config_get_value(argv[2], &v)) {
> > + if (!v)
> > + printf("(NULL)\n");
>
> This one is dubious. Is this for things like
>
> (in .git/config)
> [receive]
> fsckobjects
>Yes, it was meant for the above case.
Show 5 quoted lines
> and asking with > > $ git config receive.fsckobjects > > which I think gives an empty string? We may want to be consistent.
$ git config -l shows NULL values as foo.bar empty values as foo.bar= So there is a difference between the two. $ git config receive.fsckobjects does covert the NULL value to a ""(empty string).
I had to diffrentiate between the two, so I took the path printf takes for NULL strings, it prints them as "(NULL)".