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

Re: [PATCH 4/6] config: drop git_config_get_string_const()

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 17, 2020, 17:36 UTC
Message-ID
<xmqqft8l2mzn.fsf@gitster.c.googlers.com>
In-Reply-To
<20200815063437.GA619381@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 9 quoted lines
> Whoops, I actually meant to do so (and made sure we didn't have any
> callers) but forgot to actually include it in patch 4. It doesn't make
> any sense to keep those other variants.
>
> The diff is pretty straightforward (see below). I'll include it in a
> re-roll (squashed into patch 4), but will wait for any other comments.
>
> It doesn't look like there's any extra fallout from merging this with
> "seen".
OK, thanks.
Show 77 quoted lines
>
> diff --git a/config.c b/config.c
> index 8bb1945aa9..f0367c76ad 100644
> --- a/config.c
> +++ b/config.c
> @@ -2006,20 +2006,15 @@ const struct string_list *git_configset_get_value_multi(struct config_set *cs, c
>  	return e ? &e->value_list : NULL;
>  }
>  
> -int git_configset_get_string_const(struct config_set *cs, const char *key, const char **dest)
> +int git_configset_get_string(struct config_set *cs, const char *key, char **dest)
>  {
>  	const char *value;
>  	if (!git_configset_get_value(cs, key, &value))
> -		return git_config_string(dest, key, value);
> +		return git_config_string((const char **)dest, key, value);
>  	else
>  		return 1;
>  }
>  
> -int git_configset_get_string(struct config_set *cs, const char *key, char **dest)
> -{
> -	return git_configset_get_string_const(cs, key, (const char **)dest);
> -}
> -
>  int git_configset_get_string_tmp(struct config_set *cs, const char *key,
>  				 const char **dest)
>  {
> @@ -2161,24 +2156,17 @@ const struct string_list *repo_config_get_value_multi(struct repository *repo,
>  	return git_configset_get_value_multi(repo->config, key);
>  }
>  
> -int repo_config_get_string_const(struct repository *repo,
> -				 const char *key, const char **dest)
> +int repo_config_get_string(struct repository *repo,
> +			   const char *key, char **dest)
>  {
>  	int ret;
>  	git_config_check_init(repo);
> -	ret = git_configset_get_string_const(repo->config, key, dest);
> +	ret = git_configset_get_string(repo->config, key, dest);
>  	if (ret < 0)
>  		git_die_config(key, NULL);
>  	return ret;
>  }
>  
> -int repo_config_get_string(struct repository *repo,
> -			   const char *key, char **dest)
> -{
> -	git_config_check_init(repo);
> -	return repo_config_get_string_const(repo, key, (const char **)dest);
> -}
> -
>  int repo_config_get_string_tmp(struct repository *repo,
>  			       const char *key, const char **dest)
>  {
> diff --git a/config.h b/config.h
> index d4d22c34c6..91cdfbfb41 100644
> --- a/config.h
> +++ b/config.h
> @@ -458,7 +458,6 @@ void git_configset_clear(struct config_set *cs);
>   */
>  int git_configset_get_value(struct config_set *cs, const char *key, const char **dest);
>  
> -int git_configset_get_string_const(struct config_set *cs, const char *key, const char **dest);
>  int git_configset_get_string(struct config_set *cs, const char *key, char **dest);
>  int git_configset_get_string_tmp(struct config_set *cs, const char *key, const char **dest);
>  int git_configset_get_int(struct config_set *cs, const char *key, int *dest);
> @@ -475,8 +474,6 @@ int repo_config_get_value(struct repository *repo,
>  			  const char *key, const char **value);
>  const struct string_list *repo_config_get_value_multi(struct repository *repo,
>  						      const char *key);
> -int repo_config_get_string_const(struct repository *repo,
> -				 const char *key, const char **dest);
>  int repo_config_get_string(struct repository *repo,
>  			   const char *key, char **dest);
>  int repo_config_get_string_tmp(struct repository *repo,
Previous: Jeff KingNext: Jeff King
Message 8 of 20 in “more small leak fixes”
  1. 0/6 more small leak fixesJeff King, Aug 14, 2020
  2. 1/6 submodule--helper: use strbuf_release() to free strbufsJeff King, Aug 14, 2020
  3. 2/6 checkout: fix leak of non-existent branch namesJeff King, Aug 14, 2020
  4. 3/6 config: fix leaks from git_config_get_string_const()Jeff King, Aug 14, 2020
  5. 4/6 config: drop git_config_get_string_const()Jeff King, Aug 14, 2020
  6. Junio C HamanoAug 14, 2020
  7. Jeff KingAug 15, 2020
  8. Junio C HamanoAug 17, 2020
  9. 5/6 config: fix leak in git_config_get_expiry_in_days()Jeff King, Aug 14, 2020
  10. 6/6 submodule--helper: fix leak of core.worktree valueJeff King, Aug 14, 2020
  11. Jeff KingAug 14, 2020
  12. Jeff KingAug 14, 2020
  13. 0/7 leak fixesJeff King, Aug 17, 2020
  14. 1/7 clear_pattern_list(): clear embedded hashmapsJeff King, Aug 17, 2020
  15. 2/7 submodule--helper: use strbuf_release() to free strbufsJeff King, Aug 17, 2020
  16. 3/7 checkout: fix leak of non-existent branch namesJeff King, Aug 17, 2020
  17. 4/7 config: fix leaks from git_config_get_string_const()Jeff King, Aug 17, 2020
  18. 6/7 config: fix leak in git_config_get_expiry_in_days()Jeff King, Aug 17, 2020
  19. 7/7 submodule--helper: fix leak of core.worktree valueJeff King, Aug 17, 2020
  20. 5/7 config: drop git_config_get_string_const()Jeff King, Aug 17, 2020

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.