Skip to content

Commit 6ea358f

Browse files
tanayabhgitster
authored andcommitted
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 <[email protected]> Reviewed-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 536900e commit 6ea358f

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

ll-merge.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,8 @@ static int read_merge_config(const char *var, const char *value, void *cb)
225225
const char *key, *name;
226226
int namelen;
227227

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);
233230

234231
/*
235232
* 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)
254251
ll_user_merge_tail = &(fn->next);
255252
}
256253

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);
263256

264257
if (!strcmp("driver", key)) {
265258
if (!value)
@@ -285,12 +278,8 @@ static int read_merge_config(const char *var, const char *value, void *cb)
285278
return 0;
286279
}
287280

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);
294283

295284
return 0;
296285
}

0 commit comments

Comments
 (0)