builtin/apply: move 'no_add' global into 'struct apply_state'
To libify the apply functionality the 'no_add' 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
1ff36a107f609978dedd8c5b56aad8ca6276f975
1 file changed
+3
-3
builtin/apply.c
+3
-3
@@ -41,6 +41,7 @@ struct apply_state {
41
int apply_in_reverse;
42
int apply_with_reject;
43
int apply_verbosely;
44
+ int no_add;
45
int threeway;
46
int unidiff_zero;
47
};
@@ -53,7 +54,6 @@ static int newfd = -1;
54
static int state_p_value = 1;
55
static int p_value_known;
56
static int apply = 1;
56
-static int no_add;
57
static int unsafe_paths;
58
static const char *fake_ancestor;
59
static int line_termination = '\n';
@@ -2782,7 +2782,7 @@ static int apply_one_fragment(struct apply_state *state,
2782
/* Fall-through for ' ' */
2783
case '+':
2784
/* --no-add does not add new lines */
2785
- if (first == '+' && no_add)
2785
+ if (first == '+' && state->no_add)
2786
break;
2787
2788
start = newlines.len;
@@ -4600,7 +4600,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
4600
{ OPTION_CALLBACK, 'p', NULL, NULL, N_("num"),
4601
N_("remove <num> leading slashes from traditional diff paths"),
4602
0, option_parse_p },
4603
- OPT_BOOL(0, "no-add", &no_add,
4603
+ OPT_BOOL(0, "no-add", &state.no_add,
4604
N_("ignore additions made by the patch")),
4605
OPT_BOOL(0, "stat", &state.diffstat,
4606
N_("instead of applying the patch, output diffstat for the input")),