On 07/03/2013 12:21 AM, Junio C Hamano wrote:
> Ramkumar Ramachandra <artag...@gmail.com> writes:
>>> def get(self, name, default=''):
>>> values = self._split(read_git_output(
>>> ['config', '--get', '--null', '%s.%s' % (self.section,
>>> env=self.env, keepends=True,
>> Wait, what is the point of using --null and then splitting by hand
>> using a poorly-defined static method? Why not drop the --null and
>> splitlines() as usual?
> You may actually have spotted a bug or misuse of "--get" here.
> With this sample configuration:
> $ cat >sample <<\EOF
> one = value
> one = another
> one = "value\nanother"
> A script cannot differentiate between them without using '--null'.
> $ git config -f sample --get-all a.one
> $ git config -f sample --get-all b.one
> But that matters only when you use "--get-all", not "--get". If
> this method wants to make sure that the user did not misuse a.one
> as a multi-valued configuration variable, use of "--null --get-all"
> followed by checking how many items the command gives you back would
> be a way to do so.
No, the code in question was a simple sanity check (i.e., mostly a check
of my own sanity and understanding of "git config" behavior) preceding
the information-losing next line "return values". If it had been
meant as a check that the user hadn't misconfigured the system, then I
wouldn't have used assert but rather raised a ConfigurationException
with an explanatory message.
I would be happy to add the checking that you described, but I didn't
have the impression that it is the usual convention. Does code that
wants a single value from the config usually verify that there is
one-and-only-one value, or does it typically just do the equivalent of
"git config --get" and use the returned (effectively the last) value?
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html