Subject: Re: [PATCH/RFC] alias.c: Replace git_config with git_config_get_string

From: Tanay Abhra <[email-masked]>
Date: Tue, 17 Jun 2014 11:51:35 -0700

On 06/16/2014 10:43 PM, Jeff King wrote:

> 
>> +	v = git_config_get_string(alias_key);
>> +	if (!v)
>> +		config_error_nonbool(alias_key);
> 
> What does a NULL output from git_config_get_string mean? I think with
> the current code, it means "no such key was found".  In which case, you
> should be returning NULL here (there is no such alias), not complaining
> with config_error_nonbool.
> 

Yes, you surmised correctly. I totally skipped the fact that git_config() can
return null for values indicating a boolean value. I will correct it in the next
patch.

> Again, this is going to depend on your strategy for storing booleans
> that I mentioned elsewhere.

I have read your other two replies related to it. I suggest the following approach
for git_config_get_string(), it will return,

1. Return null if no value was found for the entered key.

2. Empty string (""), returned for NULL values denoting boolean true in some cases.
   I think it would be much better than converting NULL to "true" or something else
   internally in the function.
   We can easily handle such cases as the above with a strcmp like,

+	v = git_config_get_string(alias_key);
+	if (!strcmp(v, ""))
+		config_error_nonbool(alias_key);

What do you think about this approach?

Thanks for the suggestion, I was pulling my hair out due this bug for last two days.

Cheers,
Tanay Abhra.