git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: bmwill@google.com, git@vger.kernel.org, jrnieder@gmail.com, philipoakley@iee.org
Subject: Re: [PATCH 1/3] builtin/fetch: factor submodule recurse parsing out to submodule config
Date: Fri, 23 Jun 2017 15:26:38 -0700
Message-ID: <xmqqshiqbash.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170623191302.16053-2-sbeller@google.com>

Stefan Beller <sbeller@google.com> writes:

> Later we want to access this parsing in builtin/pull as well.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  builtin/fetch.c    | 18 ++----------------
>  submodule-config.c | 22 ++++++++++++++++++++++
>  submodule-config.h |  3 +++
>  3 files changed, 27 insertions(+), 16 deletions(-)
>
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 100248c5af..9d58dc0a8a 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -53,20 +53,6 @@ static int shown_url = 0;
>  static int refmap_alloc, refmap_nr;
>  static const char **refmap_array;
>  
> -static int option_parse_recurse_submodules(const struct option *opt,
> -				   const char *arg, int unset)
> -{
> -	if (unset) {
> -		recurse_submodules = RECURSE_SUBMODULES_OFF;
> -	} else {
> -		if (arg)
> -			recurse_submodules = parse_fetch_recurse_submodules_arg(opt->long_name, arg);
> -		else
> -			recurse_submodules = RECURSE_SUBMODULES_ON;
> -	}
> -	return 0;
> -}
> -
>  static int git_fetch_config(const char *k, const char *v, void *cb)
>  {
>  	if (!strcmp(k, "fetch.prune")) {
> @@ -115,9 +101,9 @@ static struct option builtin_fetch_options[] = {
>  		    N_("number of submodules fetched in parallel")),
>  	OPT_BOOL('p', "prune", &prune,
>  		 N_("prune remote-tracking branches no longer on remote")),
> -	{ OPTION_CALLBACK, 0, "recurse-submodules", NULL, N_("on-demand"),
> +	{ OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, N_("on-demand"),
>  		    N_("control recursive fetching of submodules"),
> -		    PARSE_OPT_OPTARG, option_parse_recurse_submodules },
> +		    PARSE_OPT_OPTARG, option_fetch_parse_recurse_submodules },
>  	OPT_BOOL(0, "dry-run", &dry_run,
>  		 N_("dry run")),
>  	OPT_BOOL('k', "keep", &keep, N_("keep downloaded pack")),
> diff --git a/submodule-config.c b/submodule-config.c
> index 4f58491ddb..265d036095 100644
> --- a/submodule-config.c
> +++ b/submodule-config.c
> @@ -2,6 +2,7 @@
>  #include "submodule-config.h"
>  #include "submodule.h"
>  #include "strbuf.h"
> +#include "parse-options.h"
>  
>  /*
>   * submodule cache lookup structure
> @@ -234,6 +235,27 @@ int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
>  	return parse_fetch_recurse(opt, arg, 1);
>  }
>  
> +int option_fetch_parse_recurse_submodules(const struct option *opt,
> +					  const char *arg, int unset)
> +{
> +	int *v;
> +
> +	if (!opt->value)
> +		return -1;

It would have been easier to view this change if the original
already had used opt->value to specify where to place the parsed
value, but that is water under the bridge ;-)

Looks like a faithful converison to me.

> +	v = opt->value;
> +
> +	if (unset) {
> +		*v = RECURSE_SUBMODULES_OFF;
> +	} else {
> +		if (arg)
> +			*v = parse_fetch_recurse_submodules_arg(opt->long_name, arg);
> +		else
> +			*v = RECURSE_SUBMODULES_ON;
> +	}
> +	return 0;
> +}
> +
>  static int parse_update_recurse(const char *opt, const char *arg,
>  				int die_on_error)
>  {
> diff --git a/submodule-config.h b/submodule-config.h
> index d434ecdb45..1076a68653 100644
> --- a/submodule-config.h
> +++ b/submodule-config.h
> @@ -23,6 +23,9 @@ struct submodule {
>  };
>  
>  extern int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
> +struct option;
> +extern int option_fetch_parse_recurse_submodules(const struct option *opt,
> +						 const char *arg, int unset);
>  extern int parse_update_recurse_submodules_arg(const char *opt, const char *arg);
>  extern int parse_push_recurse_submodules_arg(const char *opt, const char *arg);
>  extern int parse_submodule_config_option(const char *var, const char *value);

  reply index

Thread overview: 10+ messages in thread (expand / mbox.gz / Atom feed / [top])
2017-06-23 19:12 [PATCH 0/3] pull: optionally rebase submodules Stefan Beller
2017-06-23 19:13 ` [PATCH 1/3] builtin/fetch: factor submodule recurse parsing out to submodule config Stefan Beller
2017-06-23 22:26   ` Junio C Hamano [this message]
2017-06-23 19:13 ` [PATCH 2/3] builtin/fetch: parse recurse-submodules-default at default options parsing Stefan Beller
2017-06-23 22:36   ` Junio C Hamano
2017-06-23 22:49     ` Stefan Beller
2017-06-24  0:51       ` Junio C Hamano
2017-06-27  3:00         ` Stefan Beller
2017-06-27 21:31           ` [PATCH] builtin/fetch cleanup: always set default value for submodule recursing Stefan Beller
2017-06-23 19:13 ` [PATCH 3/3] pull: optionally rebase submodules (remote submodule changes only) Stefan Beller

Reply instructions:

You may reply publically 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 to all the recipients using the --to, --cc,
  and --in-reply-to switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqshiqbash.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=philipoakley@iee.org \
    --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

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox