aboutsummaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-02-28 01:12:52 -0800
committerJunio C Hamano <junkio@cox.net>2006-02-28 01:12:52 -0800
commitf21d6726150ec4219e94ea605f27a4cd58eb3d99 (patch)
tree874f98e7d640871a3c50f24873f0da5b1c9bb9a2 /apply.c
parent621603b76afe00471613ce92b78376fc57f21234 (diff)
downloadgit-f21d6726150ec4219e94ea605f27a4cd58eb3d99.tar.gz
git-f21d6726150ec4219e94ea605f27a4cd58eb3d99.tar.xz
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>
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/apply.c b/apply.c
index c4ff41800..9deb206fa 100644
--- a/apply.c
+++ b/apply.c
@@ -75,6 +75,15 @@ static void parse_whitespace_option(const char *option)
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) {