Re: [RFC PATCH v2 01/12] submodule: add a print_config_from_gitmodules() helper
- From
Stefan Beller <sbeller@google.com>
- Date
- Aug 2, 2018, 18:05 UTC
- Message-ID
- <CAGZ79ka-rbOiwWrwbW2vJW9ZOgSas23LkfmzBRLfK=g_cW=MhA@mail.gmail.com>
- In-Reply-To
- <20180802134634.10300-2-ao2@ao2.it>
On Thu, Aug 2, 2018 at 6:47 AM Antonio Ospite <ao2@ao2.it> wrote:
Show 55 quoted lines
>
> This will be used to print values just like "git config -f .gitmodules"
> would.
>
> Signed-off-by: Antonio Ospite <ao2@ao2.it>
> ---
> submodule-config.c | 25 +++++++++++++++++++++++++
> submodule-config.h | 2 ++
> 2 files changed, 27 insertions(+)
>
> diff --git a/submodule-config.c b/submodule-config.c
> index 2a7259ba8b..6f6f5f9960 100644
> --- a/submodule-config.c
> +++ b/submodule-config.c
> @@ -682,6 +682,31 @@ void submodule_free(struct repository *r)
> submodule_cache_clear(r->submodule_cache);
> }
>
> +static int config_print_callback(const char *key_, const char *value_, void *cb_data)
> +{
> + char *key = cb_data;
> +
> + if (!strcmp(key, key_))
> + printf("%s\n", value_);
> +
> + return 0;
> +}
> +
> +int print_config_from_gitmodules(const char *key)
> +{
> + int ret;
> + char *store_key;
> +
> + ret = git_config_parse_key(key, &store_key, NULL);
> + if (ret < 0)
> + return CONFIG_INVALID_KEY;
> +
> + config_from_gitmodules(config_print_callback, the_repository, store_key);
> +
> + free(store_key);
> + return 0;
> +}
> +
> struct fetch_config {
> int *max_children;
> int *recurse_submodules;
> diff --git a/submodule-config.h b/submodule-config.h
> index dc7278eea4..6fec3caadd 100644
> --- a/submodule-config.h
> +++ b/submodule-config.h
> @@ -56,6 +56,8 @@ void submodule_free(struct repository *r);
> */
> int check_submodule_name(const char *name);
>
> +extern int print_config_from_gitmodules(const char *key);The only real pushback for this patch I'd have is lack of documentation in public functions, though this is pretty self explanatory; so I'd be fine for lacking the docs here.
In case a resend is needed, please drop the extern keyword here.
Thanks, Stefan