git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Tanay Abhra <tanayabh@gmail.com>
Date
Jun 17, 2014, 18:51 UTC
Message-ID
<53A08E37.1040104@gmail.com>
In-Reply-To
<20140617054357.GC29957@sigill.intra.peff.net>
On 06/16/2014 10:43 PM, Jeff King wrote:
Show 10 quoted lines
> 
>> +	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.

Previous: Jeff KingNext: Jeff King
Message 3 of 4 in “alias.c: Replace git_config with git_config_get_string”
  1. alias.c: Replace git_config with git_config_get_stringTanay Abhra, Jun 16, 2014
  2. Jeff KingJun 17, 2014
  3. Tanay AbhraJun 17, 2014
  4. Jeff KingJun 17, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.