/* These control whitespace errors */
const char *whitespace_option;
int whitespace_error;
+ int squelch_whitespace_errors;
};
static int newfd = -1;
die_on_ws_error,
correct_ws_error
} ws_error_action = warn_on_ws_error;
-static int squelch_whitespace_errors = 5;
static int applied_after_fixing_ws;
static enum ws_ignore {
} ws_ignore_action = ignore_ws_none;
-static void parse_whitespace_option(const char *option)
+static void parse_whitespace_option(struct apply_state *state, const char *option)
{
if (!option) {
ws_error_action = warn_on_ws_error;
}
if (!strcmp(option, "error-all")) {
ws_error_action = die_on_ws_error;
- squelch_whitespace_errors = 0;
+ state->squelch_whitespace_errors = 0;
return;
}
if (!strcmp(option, "strip") || !strcmp(option, "fix")) {
return;
state->whitespace_error++;
- if (squelch_whitespace_errors &&
- squelch_whitespace_errors < state->whitespace_error)
+ if (state->squelch_whitespace_errors &&
+ state->squelch_whitespace_errors < state->whitespace_error)
return;
err = whitespace_error_string(result);
const char *arg, int unset)
{
struct apply_state *state = opt->value;
-
state->whitespace_option = arg;
- parse_whitespace_option(arg);
+ parse_whitespace_option(state, arg);
return 0;
}
state->line_termination = '\n';
state->p_value = 1;
state->p_context = UINT_MAX;
+ state->squelch_whitespace_errors = 5;
strbuf_init(&state->root, 0);
git_apply_config();
if (apply_default_whitespace)
- parse_whitespace_option(apply_default_whitespace);
+ parse_whitespace_option(state, apply_default_whitespace);
if (apply_default_ignorewhitespace)
parse_ignorewhitespace_option(apply_default_ignorewhitespace);
}
if (read_stdin)
errs |= apply_patch(&state, 0, "<stdin>", options);
if (state.whitespace_error) {
- if (squelch_whitespace_errors &&
- squelch_whitespace_errors < state.whitespace_error) {
+ if (state.squelch_whitespace_errors &&
+ state.squelch_whitespace_errors < state.whitespace_error) {
int squelched =
- state.whitespace_error - squelch_whitespace_errors;
+ state.whitespace_error - state.squelch_whitespace_errors;
warning(Q_("squelched %d whitespace error",
"squelched %d whitespace errors",
squelched),