Andrew Morton <akpm@xxxxxxxx> writes: > I'd suggest that git have options to a) generate trailing-whitespace > warnings, b) generate trailing-whitespace errors and c) strip trailing > whitespace while applying. And that the as-shipped default be a). I've done this and will be pushing it out to "master" branch on my next git day (Wednesday, west coast US); "maint" branch will have the same for v1.2.4 sometime by the end of this week. There is one thing. By making --whitespace=warn the default, the diffstat output people would see after "git pull" would also show the warning message. I personally do not think this is a problem (you will know how dirty a tree you are merging into your tree), but it might not be a bad idea to explicitly squelch it by making it not to warn when we are not applying. -- >8 -- 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@xxxxxxx> --- apply.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) f21d6726150ec4219e94ea605f27a4cd58eb3d99 diff --git a/apply.c b/apply.c index c4ff418..9deb206 100644 --- a/apply.c +++ b/apply.c @@ -75,6 +75,15 @@ static void parse_whitespace_option(cons die("unrecognized whitespace option '%s'", option); } +static void set_default_whitespace_mode(const char *whitespace_option) +{ + if (!whitespace_option && !apply_default_whitespace) { + new_whitespace = (apply + ? warn_on_whitespace + : nowarn_whitespace); + } +} + /* * For "diff-stat" like behaviour, we keep track of the biggest change * we've seen, and the longest filename. That allows us to do simple @@ -1955,9 +1964,11 @@ int main(int argc, char **argv) if (fd < 0) usage(apply_usage); read_stdin = 0; + set_default_whitespace_mode(whitespace_option); apply_patch(fd, arg); close(fd); } + set_default_whitespace_mode(whitespace_option); if (read_stdin) apply_patch(0, "<stdin>"); if (whitespace_error) { -- 1.2.3.g1da2 - : send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html