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
56248c5a5c77f65fe591dfec3ac413147d227ec4
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
@@ -1947,9 +1956,11 @@ int main(int argc, char **argv)
1956
if (fd < 0)
1957
usage(apply_usage);
1958
read_stdin = 0;
1959
+ set_default_whitespace_mode(whitespace_option);
1960
apply_patch(fd, arg);
1961
close(fd);
1962
}
1963
+ set_default_whitespace_mode(whitespace_option);
1964
if (read_stdin)
1965
apply_patch(0, "<stdin>");
1966
if (whitespace_error) {