Re: [PATCH v8 1/2] add `config_set` API for caching config-like files
- From
Tanay Abhra <tanayabh@gmail.com>
- Date
- Jul 15, 2014, 10:54 UTC
- Message-ID
- <53C50859.5070209@gmail.com>
- In-Reply-To
- <vpqlhs02cz7.fsf@anie.imag.fr>
On 7/11/2014 7:51 PM, Matthieu Moy wrote:
Show 18 quoted lines
>> +`int git_configset_add_file(struct config_set *cs, const char *filename)`:: >> + >> + Parses the file and adds the variable-value pairs to the `config_set`, >> + dies if there is an error in parsing the file. > > The return value is undocumented. > > If I read correctly, the only codepath from this to a syntax error sets > die_on_error, hence "dies if there is an error in parsing the file" is > correct. > > Still, there are errors like "unreadable file" or "no such file" that do > not die (nor emit any error message, which is not very good for the > user), and lead to returning -1 here. > > I'm not sure this distinction is right (why die on syntax error and > continue running on unreadable file?). >
I checked the whole codebase and in all of the cases if they cannot read a file they return -1 and continue running. So, I have updated the API to document the return value.
I think if the file is unreadable. we must continue running as no harm has been done yet, worse is parsing a file with wrong syntax which can cause reading wrong config values. So the decision to die on syntax error sounds alright to me.
Cheers, Tanay Abhra.