Re: [PATCH v2 33/94] builtin/apply: move 'p_value_known' global into 'struct apply_state'
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 12, 2016, 19:43 UTC
- Message-ID
- <xmqqk2izdpts.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20160511131745.2914-34-chriscool@tuxfamily.org>
Christian Couder <christian.couder@gmail.com> writes:
> To libify the apply functionality the 'p_value_known' variable should > not be static and global to the file. Let's move it into > 'struct apply_state'.
This and p_value belong together, I would think, so this can be squashed with 32/94 if the series is to be rerolled (this alone is not a reason to reroll the series, though).
Show 51 quoted lines
>
> Reviewed-by: Stefan Beller <sbeller@google.com>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---
> builtin/apply.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/builtin/apply.c b/builtin/apply.c
> index 4e476d5..30eea9c 100644
> --- a/builtin/apply.c
> +++ b/builtin/apply.c
> @@ -63,13 +63,12 @@ struct apply_state {
> int line_termination;
>
> int p_value;
> + int p_value_known;
> unsigned int p_context;
> };
>
> static int newfd = -1;
>
> -static int p_value_known;
> -
> static const char * const apply_usage[] = {
> N_("git apply [<options>] [<patch>...]"),
> NULL
> @@ -882,14 +881,14 @@ static void parse_traditional_patch(struct apply_state *state,
>
> first += 4; /* skip "--- " */
> second += 4; /* skip "+++ " */
> - if (!p_value_known) {
> + if (!state->p_value_known) {
> int p, q;
> p = guess_p_value(state, first);
> q = guess_p_value(state, second);
> if (p < 0) p = q;
> if (0 <= p && p == q) {
> state->p_value = p;
> - p_value_known = 1;
> + state->p_value_known = 1;
> }
> }
> if (is_dev_null(first)) {
> @@ -4595,7 +4594,7 @@ static int option_parse_p(const struct option *opt,
> {
> struct apply_state *state = opt->value;
> state->p_value = atoi(arg);
> - p_value_known = 1;
> + state->p_value_known = 1;
> return 0;
> }