git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Antonio Ospite <ao2@ao2.it>
Cc: git@vger.kernel.org, Brandon Williams <bmwill@google.com>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Stefan Beller <sbeller@google.com>, Jeff King <peff@peff.net>
Subject: Re: [PATCH v2 2/6] submodule-config: add helper function to get 'fetch' config from .gitmodules
Date: Tue, 26 Jun 2018 13:11:40 -0700	[thread overview]
Message-ID: <xmqqfu19jojn.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20180626104710.9859-3-ao2@ao2.it> (Antonio Ospite's message of "Tue, 26 Jun 2018 12:47:06 +0200")

Antonio Ospite <ao2@ao2.it> writes:

> Add a helper function to make it clearer that retrieving 'fetch'
> configuration from the .gitmodules file is a special case supported
> solely for backward compatibility purposes.
> ...

Then perhaps the new public function deserves a comment stating
that?

> +struct fetch_config {
> +	int *max_children;
> +	int *recurse_submodules;
> +};
> +
> +static int gitmodules_fetch_config(const char *var, const char *value, void *cb)
> +{
> +	struct fetch_config *config = cb;
> +	if (!strcmp(var, "submodule.fetchjobs")) {
> +		*(config->max_children) = parse_submodule_fetchjobs(var, value);
> +		return 0;
> +	} else if (!strcmp(var, "fetch.recursesubmodules")) {
> +		*(config->recurse_submodules) = parse_fetch_recurse_submodules_arg(var, value);
> +		return 0;
> +	}
> +
> +	return 0;
> +}
> +
> +void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
> +{
> +	struct fetch_config config = {
> +		.max_children = max_children,
> +		.recurse_submodules = recurse_submodules
> +	};

We started using designated initializers some time ago, and use of
it improves readability of something like this ;-)

> +	config_from_gitmodules(gitmodules_fetch_config, &config);
> +}
> diff --git a/submodule-config.h b/submodule-config.h
> index 5148801f4..cff297a75 100644
> --- a/submodule-config.h
> +++ b/submodule-config.h
> @@ -66,4 +66,6 @@ int check_submodule_name(const char *name);
>   */
>  extern void config_from_gitmodules(config_fn_t fn, void *data);
>  
> +extern void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules);
> +
>  #endif /* SUBMODULE_CONFIG_H */

  reply	other threads:[~2018-06-26 20:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-26 10:47 [PATCH v2 0/6] Restrict the usage of config_from_gitmodules to submodule-config Antonio Ospite
2018-06-26 10:47 ` [PATCH v2 1/6] config: move config_from_gitmodules to submodule-config.c Antonio Ospite
2018-06-26 10:47 ` [PATCH v2 2/6] submodule-config: add helper function to get 'fetch' config from .gitmodules Antonio Ospite
2018-06-26 20:11   ` Junio C Hamano [this message]
2018-06-26 20:55     ` Antonio Ospite
2018-06-26 10:47 ` [PATCH v2 3/6] submodule-config: add helper to get 'update-clone' " Antonio Ospite
2018-06-26 10:47 ` [PATCH v2 4/6] submodule-config: make 'config_from_gitmodules' private Antonio Ospite
2018-06-26 20:15   ` Junio C Hamano
2018-06-26 10:47 ` [PATCH v2 5/6] submodule-config: pass repository as argument to config_from_gitmodules Antonio Ospite
2018-06-26 20:15   ` Junio C Hamano
2018-06-26 20:57     ` Antonio Ospite
2018-06-26 10:47 ` [PATCH v2 6/6] submodule-config: reuse config_from_gitmodules in repo_read_gitmodules Antonio Ospite
2018-06-26 17:05 ` [PATCH v2 0/6] Restrict the usage of config_from_gitmodules to submodule-config Brandon Williams
2018-06-26 20:24   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqfu19jojn.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=ao2@ao2.it \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).