builtin/apply: move 'applied_after_fixing_ws' into 'struct apply_state'
To libify the apply functionality the 'applied_after_fixing_ws' 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
7243f5f3507abe3d083ec18e44bc7cb464fa06f4
1 file changed
+5
-5
builtin/apply.c
+5
-5
@@ -64,6 +64,7 @@ struct apply_state {
64
const char *whitespace_option;
65
int whitespace_error;
66
int squelch_whitespace_errors;
67
+ int applied_after_fixing_ws;
68
};
69
70
static int newfd = -1;
@@ -79,7 +80,6 @@ static enum ws_error_action {
80
die_on_ws_error,
81
correct_ws_error
82
} ws_error_action = warn_on_ws_error;
82
-static int applied_after_fixing_ws;
83
84
static enum ws_ignore {
85
ignore_ws_none,
@@ -2862,7 +2862,7 @@ static int apply_one_fragment(struct apply_state *state,
2862
strbuf_add(&newlines, patch + 1, plen);
2863
}
2864
else {
2865
- ws_fix_copy(&newlines, patch + 1, plen, ws_rule, &applied_after_fixing_ws);
2865
+ ws_fix_copy(&newlines, patch + 1, plen, ws_rule, &state->applied_after_fixing_ws);
2866
}
2867
add_line_info(&postimage, newlines.buf + start, newlines.len - start,
2868
(first == '+' ? 0 : LINE_COMMON));
@@ -4806,11 +4806,11 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
4806
"%d lines add whitespace errors.",
4807
state.whitespace_error),
4808
state.whitespace_error);
4809
- if (applied_after_fixing_ws && state.apply)
4809
+ if (state.applied_after_fixing_ws && state.apply)
4810
warning("%d line%s applied after"
4811
" fixing whitespace errors.",
4812
- applied_after_fixing_ws,
4813
- applied_after_fixing_ws == 1 ? "" : "s");
4812
+ state.applied_after_fixing_ws,
4813
+ state.applied_after_fixing_ws == 1 ? "" : "s");
4814
else if (state.whitespace_error)
4815
warning(Q_("%d line adds whitespace errors.",
4816
"%d lines add whitespace errors.",