Re: [PATCH v2 09/94] builtin/apply: move 'state' init into init_apply_state()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Christian Couder <christian.couder@xxxxxxxxx> writes:

> When the apply functionality will be libified, the 'struct apply_state'
> will be used by different pieces of code.
>
> To properly initialize a 'struct apply_state', let's provide a nice
> and easy to use init_apply_state() function.

This probably should be done at 08/94, but I'll let it pass for now.
I am hoping 'prefix' is just one of a very few parameters this
function needs to take to initialize this (I do not think we want to
feed many different parameters to this function to initialize).

Will queue.

> Helped-by: Eric Sunshine <sunshine@xxxxxxxxxxxxxx>
> Reviewed-by: Stefan Beller <sbeller@xxxxxxxxxx>
> Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx>
> ---
>  builtin/apply.c | 23 ++++++++++++++---------
>  1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/builtin/apply.c b/builtin/apply.c
> index ae068e7..e133033 100644
> --- a/builtin/apply.c
> +++ b/builtin/apply.c
> @@ -4522,6 +4522,19 @@ static int option_parse_directory(const struct option *opt,
>  	return 0;
>  }
>  
> +static void init_apply_state(struct apply_state *state, const char *prefix)
> +{
> +	memset(state, 0, sizeof(*state));
> +	state->prefix = prefix;
> +	state->prefix_length = state->prefix ? strlen(state->prefix) : 0;
> +
> +	git_apply_config();
> +	if (apply_default_whitespace)
> +		parse_whitespace_option(apply_default_whitespace);
> +	if (apply_default_ignorewhitespace)
> +		parse_ignorewhitespace_option(apply_default_ignorewhitespace);
> +}
> +
>  int cmd_apply(int argc, const char **argv, const char *prefix_)
>  {
>  	int i;
> @@ -4603,15 +4616,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix_)
>  		OPT_END()
>  	};
>  
> -	memset(&state, 0, sizeof(state));
> -	state.prefix = prefix_;
> -	state.prefix_length = state.prefix ? strlen(state.prefix) : 0;
> -
> -	git_apply_config();
> -	if (apply_default_whitespace)
> -		parse_whitespace_option(apply_default_whitespace);
> -	if (apply_default_ignorewhitespace)
> -		parse_ignorewhitespace_option(apply_default_ignorewhitespace);
> +	init_apply_state(&state, prefix_);
>  
>  	argc = parse_options(argc, argv, state.prefix, builtin_apply_options,
>  			apply_usage, 0);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]