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>
Tanay Abhra committed
Aug 13, 2014 at 18:13 UTC
6ea358f784a5d8823565a8574d8ed914e51096f4
1 file changed
+6
-17
ll-merge.c
+6
-17
@@ -225,11 +225,8 @@ static int read_merge_config(const char *var, const char *value, void *cb)
225
const char *key, *name;
226
int namelen;
227
228
- if (!strcmp(var, "merge.default")) {
229
- if (value)
230
- default_ll_merge = xstrdup(value);
231
- return 0;
232
- }
228
+ if (!strcmp(var, "merge.default"))
229
+ return git_config_string(&default_ll_merge, var, value);
230
231
/*
232
* 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)
251
ll_user_merge_tail = &(fn->next);
252
}
253
257
- if (!strcmp("name", key)) {
258
- if (!value)
259
- return error("%s: lacks value", var);
260
- fn->description = xstrdup(value);
261
- return 0;
262
- }
254
+ if (!strcmp("name", key))
255
+ return git_config_string(&fn->description, var, value);
256
257
if (!strcmp("driver", key)) {
258
if (!value)
@@ -285,12 +278,8 @@ static int read_merge_config(const char *var, const char *value, void *cb)
278
return 0;
279
}
280
288
- if (!strcmp("recursive", key)) {
289
- if (!value)
290
- return error("%s: lacks value", var);
291
- fn->recursive = xstrdup(value);
292
- return 0;
293
- }
281
+ if (!strcmp("recursive", key))
282
+ return git_config_string(&fn->recursive, var, value);
283
284
return 0;
285
}