Skip to content

Commit f21d672

Browse files
author
Junio C Hamano
committed
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>
1 parent 621603b commit f21d672

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

apply.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ static void parse_whitespace_option(const char *option)
7575
die("unrecognized whitespace option '%s'", option);
7676
}
7777

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+
7887
/*
7988
* For "diff-stat" like behaviour, we keep track of the biggest change
8089
* we've seen, and the longest filename. That allows us to do simple
@@ -1955,9 +1964,11 @@ int main(int argc, char **argv)
19551964
if (fd < 0)
19561965
usage(apply_usage);
19571966
read_stdin = 0;
1967+
set_default_whitespace_mode(whitespace_option);
19581968
apply_patch(fd, arg);
19591969
close(fd);
19601970
}
1971+
set_default_whitespace_mode(whitespace_option);
19611972
if (read_stdin)
19621973
apply_patch(0, "<stdin>");
19631974
if (whitespace_error) {

0 commit comments

Comments
 (0)