Re: [PATCH 1/8] submodule-config: keep update strategy around
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 3, 2016, 23:09 UTC
- Message-ID
- <xmqqy4b1l7cd.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1454435497-26429-2-git-send-email-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 34 quoted lines
> We need the submodule update strategies in a later patch.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> submodule-config.c | 11 +++++++++++
> submodule-config.h | 1 +
> 2 files changed, 12 insertions(+)
>
> diff --git a/submodule-config.c b/submodule-config.c
> index afe0ea8..4239b0e 100644
> --- a/submodule-config.c
> +++ b/submodule-config.c
> @@ -194,6 +194,7 @@ static struct submodule *lookup_or_create_by_name(struct submodule_cache *cache,
>
> submodule->path = NULL;
> submodule->url = NULL;
> + submodule->update = NULL;
> submodule->fetch_recurse = RECURSE_SUBMODULES_NONE;
> submodule->ignore = NULL;
>
> @@ -311,6 +312,16 @@ static int parse_config(const char *var, const char *value, void *data)
> free((void *) submodule->url);
> submodule->url = xstrdup(value);
> }
> + } else if (!strcmp(item.buf, "update")) {
> + if (!value)
> + ret = config_error_nonbool(var);
> + else if (!me->overwrite && submodule->update != NULL)
> + warn_multiple_config(me->commit_sha1, submodule->name,
> + "update");
> + else {
> + free((void *) submodule->update);
> + submodule->update = xstrdup(value);This is a tangent, but whenever I see us needing to cast the constness away to call free(), it makes me wonder how much value we are getting by marking the field as a pointer to "const" in the first place. With this patch alone, we cannot really see it, because we cannot see how it is used.
Show 16 quoted lines
> + }
> }
>
> strbuf_release(&name);
> diff --git a/submodule-config.h b/submodule-config.h
> index 9061e4e..f9e2a29 100644
> --- a/submodule-config.h
> +++ b/submodule-config.h
> @@ -14,6 +14,7 @@ struct submodule {
> const char *url;
> int fetch_recurse;
> const char *ignore;
> + const char *update;
> /* the sha1 blob id of the responsible .gitmodules file */
> unsigned char gitmodules_sha1[20];
> };