git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/4] ll-merge.c: refactor `read_merge_config()` to use `git_config_string()`

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 13, 2014, 17:07 UTC
Message-ID
<xmqqd2c448tq.fsf@gitster.dls.corp.google.com>
In-Reply-To
<53EB5D58.7000300@gmail.com>
Tanay Abhra <tanayabh@gmail.com> writes:
Show 5 quoted lines
> 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.
Better explained than v1 ;-)
Show 8 quoted lines
> Signed-off-by: Tanay Abhra <tanayabh@gmail.com>
> ---
> We cannot easily use the new config-set API here, because
> much of the function is dedicated to processing
> "merge.<name>.variable" which does not easily translate to
> the new API. If it were for variables like,
> "merge.summary", "merge.tool", and "merge.verbosity", we
> could use the new API.

I think this comment belongs to the log message, if only to serve as a reminder for us that the API needs to be made more usable when the caller wants to use these three-level names, which are quite common. This code path knows the name of a low-level merge driver and wants to learn everything about that driver. Another code path may know the name of the branch and may want to scan "branch.<name>.*".

Show 51 quoted lines
>  ll-merge.c | 23 ++++++-----------------
>  1 file changed, 6 insertions(+), 17 deletions(-)
>
> diff --git a/ll-merge.c b/ll-merge.c
> index fb61ea6..8ea03e5 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;
>  }
Previous: Matthieu MoyNext: Tanay Abhra
Message 6 of 19 in “fast-import.c: replace `git_config()` with `git_config_get_*()` family”
  1. 1/4 fast-import.c: replace `git_config()` with `git_config_get_*()` familyTanay Abhra, Aug 13, 2014
  2. 2/4 ll-merge.c: refactor `read_merge_config()` to use `git_config_string()`Tanay Abhra, Aug 13, 2014
  3. Matthieu MoyAug 13, 2014
  4. 2/4 ll-merge.c: refactor `read_merge_config()` to use `git_config_string()`Tanay Abhra, Aug 13, 2014
  5. Matthieu MoyAug 13, 2014
  6. Junio C HamanoAug 13, 2014
  7. 3/4 merge-recursive.c: replace `git_config()` with `git_config_get_int()`Tanay Abhra, Aug 13, 2014
  8. Matthieu MoyAug 13, 2014
  9. 4/4 builtin/apply.c: replace `git_config()` with `git_config_get_string_const()`Tanay Abhra, Aug 13, 2014
  10. Matthieu MoyAug 13, 2014
  11. Tanay AbhraAug 13, 2014
  12. 1/5 fast-import.c: replace `git_config()` with `git_config_get_*()` familyTanay Abhra, Aug 13, 2014
  13. Matthieu MoyAug 13, 2014
  14. 1/2 git_default_config() rewritten using the config-set APITanay Abhra, Aug 13, 2014
  15. 2/2 use the new git_default_config()Tanay Abhra, Aug 13, 2014
  16. Matthieu MoyAug 13, 2014
  17. Junio C HamanoAug 13, 2014
  18. Matthieu MoyAug 13, 2014
  19. Junio C HamanoAug 13, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.