git-apply: war on whitespace -- finishing touches.
This changes the default --whitespace policy to nowarn when we are only getting --stat, --summary etc. IOW when not applying the patch. When applying the patch, the default is warn (spit out warning message but apply the patch). Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Feb 28, 2006 at 01:12 UTC
f21d6726150ec4219e94ea605f27a4cd58eb3d99
1 file changed
+11
apply.c
+11
@@ -75,6 +75,15 @@ static void parse_whitespace_option(const char *option)
75
die("unrecognized whitespace option '%s'", option);
76
}
77
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
+
87
/*
88
* For "diff-stat" like behaviour, we keep track of the biggest change
89
* we've seen, and the longest filename. That allows us to do simple
@@ -1955,9 +1964,11 @@ int main(int argc, char **argv)
1964
if (fd < 0)
1965
usage(apply_usage);
1966
read_stdin = 0;
1967
+ set_default_whitespace_mode(whitespace_option);
1968
apply_patch(fd, arg);
1969
close(fd);
1970
}
1971
+ set_default_whitespace_mode(whitespace_option);
1972
if (read_stdin)
1973
apply_patch(0, "<stdin>");
1974
if (whitespace_error) {