builtin/apply: move 'p_value_known' global into 'struct apply_state'

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'. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed May 24, 2016 at 10:11 UTC b76184e41003c6bd4731d79474c72449f854b37c
1 file changed +4 -5
builtin/apply.c
+4 -5
@@ -52,6 +52,7 @@ struct apply_state {
52 const char *patch_input_file;
53 int line_termination;
54 int p_value;
55 + int p_value_known;
56 unsigned int p_context;
57
58 /* Exclude and include path parameters */
@@ -61,8 +62,6 @@ struct apply_state {
62
63 static int newfd = -1;
64
64 -static int p_value_known;
65 -
65 static const char * const apply_usage[] = {
66 N_("git apply [<options>] [<patch>...]"),
67 NULL
@@ -875,14 +874,14 @@ static void parse_traditional_patch(struct apply_state *state,
874
875 first += 4; /* skip "--- " */
876 second += 4; /* skip "+++ " */
878 - if (!p_value_known) {
877 + if (!state->p_value_known) {
878 int p, q;
879 p = guess_p_value(state, first);
880 q = guess_p_value(state, second);
881 if (p < 0) p = q;
882 if (0 <= p && p == q) {
883 state->p_value = p;
885 - p_value_known = 1;
884 + state->p_value_known = 1;
885 }
886 }
887 if (is_dev_null(first)) {
@@ -4588,7 +4587,7 @@ static int option_parse_p(const struct option *opt,
4587 {
4588 struct apply_state *state = opt->value;
4589 state->p_value = atoi(arg);
4591 - p_value_known = 1;
4590 + state->p_value_known = 1;
4591 return 0;
4592 }
4593