diff options
author | Junio C Hamano <junkio@cox.net> | 2006-02-28 01:14:56 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-02-28 01:14:56 -0800 |
commit | a369bbfcc080239e523048b033623414a108a3e6 (patch) | |
tree | e3dc204d2081eacc6d0aeb3f9703d97956368e2a | |
parent | Merge branch 'master' into next (diff) | |
parent | git-apply: war on whitespace -- finishing touches. (diff) | |
download | tgif-a369bbfcc080239e523048b033623414a108a3e6.tar.xz |
Merge branch 'lt/apply' into next
* lt/apply:
git-apply: war on whitespace -- finishing touches.
git-apply --whitespace=nowarn
-rw-r--r-- | apply.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -39,7 +39,7 @@ static enum whitespace_eol { warn_on_whitespace, error_on_whitespace, strip_whitespace, -} new_whitespace = nowarn_whitespace; +} new_whitespace = warn_on_whitespace; static int whitespace_error = 0; static int squelch_whitespace_errors = 5; static int applied_after_stripping = 0; @@ -48,13 +48,17 @@ static const char *patch_input_file = NULL; static void parse_whitespace_option(const char *option) { if (!option) { - new_whitespace = nowarn_whitespace; + new_whitespace = warn_on_whitespace; return; } if (!strcmp(option, "warn")) { new_whitespace = warn_on_whitespace; return; } + if (!strcmp(option, "nowarn")) { + new_whitespace = nowarn_whitespace; + return; + } if (!strcmp(option, "error")) { new_whitespace = error_on_whitespace; return; @@ -71,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 @@ -1951,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) { |