summaryrefslogtreecommitdiff
path: root/ll-merge.c
diff options
context:
space:
mode:
authorTanay Abhra <tanayabh@gmail.com>2014-08-13 18:13:04 +0530
committerJunio C Hamano <gitster@pobox.com>2014-08-13 12:36:21 -0700
commit6ea358f784a5d8823565a8574d8ed914e51096f4 (patch)
treefe0c013813343fdb0ea31e6d10595aece4feff27 /ll-merge.c
parent536900e5b24f8341bcaf2a26371fcd3ca417eef9 (diff)
downloadgit-6ea358f784a5d8823565a8574d8ed914e51096f4.tar.gz
ll-merge.c: refactor `read_merge_config()` to use `git_config_string()`
There is one slight behavior change, previously "merge.default" silently ignored a NULL value and didn't raise any error. But, in the same function, all other values raise an error on a NULL value. So to conform with other call sites in Git, a NULL value for "merge.default" raises an error. The the new config-set API is not very useful here, because much of the function is dedicated to processing "merge.<name>.variable", which the new API does not handle well. If it were for variables like, "merge.summary", "merge.tool", and "merge.verbosity", we could use the new API. Signed-off-by: Tanay Abhra <tanayabh@gmail.com> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'll-merge.c')
-rw-r--r--ll-merge.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/ll-merge.c b/ll-merge.c
index fb61ea66a1..8ea03e536a 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -225,11 +225,8 @@ static int read_merge_config(const char *var, const char *value, void *cb)
const char *key, *name;
int namelen;
- if (!strcmp(var, "merge.default")) {
- if (value)
- default_ll_merge = xstrdup(value);
- return 0;
- }
+ if (!strcmp(var, "merge.default"))
+ return git_config_string(&default_ll_merge, var, value);
/*
* We are not interested in anything but "merge.<name>.variable";
@@ -254,12 +251,8 @@ static int read_merge_config(const char *var, const char *value, void *cb)
ll_user_merge_tail = &(fn->next);
}
- if (!strcmp("name", key)) {
- if (!value)
- return error("%s: lacks value", var);
- fn->description = xstrdup(value);
- return 0;
- }
+ if (!strcmp("name", key))
+ return git_config_string(&fn->description, var, value);
if (!strcmp("driver", key)) {
if (!value)
@@ -285,12 +278,8 @@ static int read_merge_config(const char *var, const char *value, void *cb)
return 0;
}
- if (!strcmp("recursive", key)) {
- if (!value)
- return error("%s: lacks value", var);
- fn->recursive = xstrdup(value);
- return 0;
- }
+ if (!strcmp("recursive", key))
+ return git_config_string(&fn->recursive, var, value);
return 0;
}