Re: [PATCH/RFC] rewrite `git_default_config()` using config-set API functions

2014-07-22 Thread Matthieu Moy
Junio C Hamano writes: > Matthieu Moy writes: > >> In general, most strings one manipulates are "const char *", it's >> frequent to modify a pointer to a string, but rather rare to modify the >> string itself. > > We seem to have a disagreement. Unlike git_config_get_value() that > lets callers

Re: [PATCH/RFC] rewrite `git_default_config()` using config-set API functions

2014-07-21 Thread Junio C Hamano
Matthieu Moy writes: > In general, most strings one manipulates are "const char *", it's > frequent to modify a pointer to a string, but rather rare to modify the > string itself. We seem to have a disagreement. Unlike git_config_get_value() that lets callers peek the only cached copy, git_conf

Re: [PATCH/RFC] rewrite `git_default_config()` using config-set API functions

2014-07-21 Thread Matthieu Moy
Tanay Abhra writes: >> >>> + if > + git_config_get_string("core.notesref", (const >>> char**)¬es_ref_name); >> >> This cast is needed only because notes_ref_name is declared as >> non-const, but a better fix would be to make the variable const, and >> remove the cast. > > Same casts had to

Re: [PATCH/RFC] rewrite `git_default_config()` using config-set API functions

2014-07-21 Thread Tanay Abhra
> >> +if > + git_config_get_string("core.notesref", (const >> char**)¬es_ref_name); > > This cast is needed only because notes_ref_name is declared as > non-const, but a better fix would be to make the variable const, and > remove the cast. Same casts had to be used in imap-send.c patch,

Re: [PATCH/RFC] rewrite `git_default_config()` using config-set API functions

2014-07-21 Thread Ramsay Jones
On 21/07/14 12:44, Tanay Abhra wrote: > Use `git_config_get_*()` family instead of `git_config()` to take advantage of > the config-set API which provides a cleaner control flow. > > Signed-off-by: Tanay Abhra > --- > Consider this as a proof of concept as the others callers have to be rewritten

Re: [PATCH/RFC] rewrite `git_default_config()` using config-set API functions

2014-07-21 Thread Matthieu Moy
Tanay Abhra writes: > Consider this as a proof of concept as the others callers have to be rewritten > as well. > I think that it is not so buggy as it passes all the tests. Before and after your patch, git_default_config() is called once per config key. Before the patch, it made sense, but afte

[PATCH/RFC] rewrite `git_default_config()` using config-set API functions

2014-07-21 Thread Tanay Abhra
Use `git_config_get_*()` family instead of `git_config()` to take advantage of the config-set API which provides a cleaner control flow. Signed-off-by: Tanay Abhra --- Consider this as a proof of concept as the others callers have to be rewritten as well. I think that it is not so buggy as it pas