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

2014-07-22 Thread Matthieu Moy
Junio C Hamano gits...@pobox.com writes: Matthieu Moy matthieu@grenoble-inp.fr 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

[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 tanay...@gmail.com --- Consider this as a proof of concept as the others callers have to be rewritten as well. I think that it is not

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

2014-07-21 Thread Matthieu Moy
Tanay Abhra tanay...@gmail.com 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

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 tanay...@gmail.com --- Consider this as a proof of concept as the others callers have 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**)notes_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, I will

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

2014-07-21 Thread Matthieu Moy
Tanay Abhra tanay...@gmail.com writes: + if + git_config_get_string(core.notesref, (const char**)notes_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 Junio C Hamano
Matthieu Moy matthieu@grenoble-inp.fr 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