Skip to content

Commit a369bbf

Browse files
author
Junio C Hamano
committed
Merge branch 'lt/apply' into next
* lt/apply: git-apply: war on whitespace -- finishing touches. git-apply --whitespace=nowarn
2 parents 6d5e6ff + f21d672 commit a369bbf

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

apply.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static enum whitespace_eol {
3939
warn_on_whitespace,
4040
error_on_whitespace,
4141
strip_whitespace,
42-
} new_whitespace = nowarn_whitespace;
42+
} new_whitespace = warn_on_whitespace;
4343
static int whitespace_error = 0;
4444
static int squelch_whitespace_errors = 5;
4545
static int applied_after_stripping = 0;
@@ -48,13 +48,17 @@ static const char *patch_input_file = NULL;
4848
static void parse_whitespace_option(const char *option)
4949
{
5050
if (!option) {
51-
new_whitespace = nowarn_whitespace;
51+
new_whitespace = warn_on_whitespace;
5252
return;
5353
}
5454
if (!strcmp(option, "warn")) {
5555
new_whitespace = warn_on_whitespace;
5656
return;
5757
}
58+
if (!strcmp(option, "nowarn")) {
59+
new_whitespace = nowarn_whitespace;
60+
return;
61+
}
5862
if (!strcmp(option, "error")) {
5963
new_whitespace = error_on_whitespace;
6064
return;
@@ -71,6 +75,15 @@ static void parse_whitespace_option(const char *option)
7175
die("unrecognized whitespace option '%s'", option);
7276
}
7377

78+
static void set_default_whitespace_mode(const char *whitespace_option)
79+
{
80+
if (!whitespace_option && !apply_default_whitespace) {
81+
new_whitespace = (apply
82+
? warn_on_whitespace
83+
: nowarn_whitespace);
84+
}
85+
}
86+
7487
/*
7588
* For "diff-stat" like behaviour, we keep track of the biggest change
7689
* we've seen, and the longest filename. That allows us to do simple
@@ -1951,9 +1964,11 @@ int main(int argc, char **argv)
19511964
if (fd < 0)
19521965
usage(apply_usage);
19531966
read_stdin = 0;
1967+
set_default_whitespace_mode(whitespace_option);
19541968
apply_patch(fd, arg);
19551969
close(fd);
19561970
}
1971+
set_default_whitespace_mode(whitespace_option);
19571972
if (read_stdin)
19581973
apply_patch(0, "<stdin>");
19591974
if (whitespace_error) {

0 commit comments

Comments
 (0)