From: Lars Schneider <larsxschneider@xxxxxxxxx> Refactor conversion driver config parsing to ease the parsing of new configs in a subsequent patch. No functional change intended. Signed-off-by: Lars Schneider <larsxschneider@xxxxxxxxx> --- convert.c | 64 +++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/convert.c b/convert.c index 64d0d30e08..949bc783e4 100644 --- a/convert.c +++ b/convert.c @@ -1003,43 +1003,43 @@ static int read_convert_config(const char *var, const char *value, void *cb) int namelen; struct convert_driver *drv; - /* - * External conversion drivers are configured using - * "filter.<name>.variable". - */ - if (parse_config_key(var, "filter", &name, &namelen, &key) < 0 || !name) - return 0; - for (drv = user_convert; drv; drv = drv->next) - if (!strncmp(drv->name, name, namelen) && !drv->name[namelen]) - break; - if (!drv) { - drv = xcalloc(1, sizeof(struct convert_driver)); - drv->name = xmemdupz(name, namelen); - *user_convert_tail = drv; - user_convert_tail = &(drv->next); - } + if (parse_config_key(var, "filter", &name, &namelen, &key) >= 0 && name) { + /* + * External conversion drivers are configured using + * "filter.<name>.variable". + */ + for (drv = user_convert; drv; drv = drv->next) + if (!strncmp(drv->name, name, namelen) && !drv->name[namelen]) + break; + if (!drv) { + drv = xcalloc(1, sizeof(struct convert_driver)); + drv->name = xmemdupz(name, namelen); + *user_convert_tail = drv; + user_convert_tail = &(drv->next); + } - /* - * filter.<name>.smudge and filter.<name>.clean specifies - * the command line: - * - * command-line - * - * The command-line will not be interpolated in any way. - */ + /* + * filter.<name>.smudge and filter.<name>.clean specifies + * the command line: + * + * command-line + * + * The command-line will not be interpolated in any way. + */ - if (!strcmp("smudge", key)) - return git_config_string(&drv->smudge, var, value); + if (!strcmp("smudge", key)) + return git_config_string(&drv->smudge, var, value); - if (!strcmp("clean", key)) - return git_config_string(&drv->clean, var, value); + if (!strcmp("clean", key)) + return git_config_string(&drv->clean, var, value); - if (!strcmp("process", key)) - return git_config_string(&drv->process, var, value); + if (!strcmp("process", key)) + return git_config_string(&drv->process, var, value); - if (!strcmp("required", key)) { - drv->required = git_config_bool(var, value); - return 0; + if (!strcmp("required", key)) { + drv->required = git_config_bool(var, value); + return 0; + } } return 0; -- 2.18.0