@@ -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 ;
4343static int whitespace_error = 0 ;
4444static int squelch_whitespace_errors = 5 ;
4545static int applied_after_stripping = 0 ;
@@ -48,13 +48,17 @@ static const char *patch_input_file = NULL;
4848static 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