Re: [PATCH] submodule-config: use explicit empty string instead of strbuf in config_from()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 19, 2016, 19:15 UTC
- Message-ID
- <xmqqd1m9fnhj.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <578E7A07.8080006@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 31 quoted lines
> Use a string constant instead of an empty strbuf to shorten the code
> and make it easier to read.
>
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---
> ... unless someone can come up with a suitable non-empty string to feed
> to git_config_from_mem() as its name parameter.
>
> submodule-config.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/submodule-config.c b/submodule-config.c
> index db1847f..44eb162 100644
> --- a/submodule-config.c
> +++ b/submodule-config.c
> @@ -397,7 +397,6 @@ static const struct submodule *config_from(struct submodule_cache *cache,
> const unsigned char *commit_sha1, const char *key,
> enum lookup_type lookup_type)
> {
> - struct strbuf rev = STRBUF_INIT;
> unsigned long config_size;
> char *config;
> unsigned char sha1[20];
> @@ -448,7 +447,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
> parameter.commit_sha1 = commit_sha1;
> parameter.gitmodules_sha1 = sha1;
> parameter.overwrite = 0;
> - git_config_from_mem(parse_config, "submodule-blob", rev.buf,
> + git_config_from_mem(parse_config, "submodule-blob", "",
> config, config_size, ¶meter);
> free(config);Oh.
I wondered if we used to do something useful with rev and later that useful thing was removed leaving an always-empty strbuf, but it appears that this strbuf was introduced to always hold an empty string and nothing else, which shows the (lack of) quality of reviews in this area X-<.
Will apply. Thanks.