projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into next
[git.git]
/
apply.c
diff --git
a/apply.c
b/apply.c
index
a5cdd8e
..
179b3bb
100644
(file)
--- a/
apply.c
+++ b/
apply.c
@@
-32,14
+32,14
@@
static int no_add = 0;
static int show_index_info = 0;
static int line_termination = '\n';
static const char apply_usage[] =
static int show_index_info = 0;
static int line_termination = '\n';
static const char apply_usage[] =
-"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [-z] [-pNUM] <patch>...";
+"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [-z] [-pNUM]
[--whitespace=<nowarn|warn|error|error-all|strip>]
<patch>...";
static enum whitespace_eol {
nowarn_whitespace,
warn_on_whitespace,
error_on_whitespace,
strip_whitespace,
static enum whitespace_eol {
nowarn_whitespace,
warn_on_whitespace,
error_on_whitespace,
strip_whitespace,
-} new_whitespace =
nowar
n_whitespace;
+} new_whitespace =
warn_o
n_whitespace;
static int whitespace_error = 0;
static int squelch_whitespace_errors = 5;
static int applied_after_stripping = 0;
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) {
static void parse_whitespace_option(const char *option)
{
if (!option) {
- new_whitespace =
nowar
n_whitespace;
+ new_whitespace =
warn_o
n_whitespace;
return;
}
if (!strcmp(option, "warn")) {
new_whitespace = warn_on_whitespace;
return;
}
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;
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);
}
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
/*
* 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
@@
-638,7
+651,7
@@
static int parse_git_header(char *line, int len, unsigned int size, struct patch
len = linelen(line, size);
if (!len || line[len-1] != '\n')
break;
len = linelen(line, size);
if (!len || line[len-1] != '\n')
break;
- for (i = 0; i <
sizeof(optable) / sizeof(optable[0]
); i++) {
+ for (i = 0; i <
ARRAY_SIZE(optable
); i++) {
const struct opentry *p = optable + i;
int oplen = strlen(p->str);
if (len < oplen || memcmp(p->str, line, oplen))
const struct opentry *p = optable + i;
int oplen = strlen(p->str);
if (len < oplen || memcmp(p->str, line, oplen))
@@
-1389,7
+1402,8
@@
static int check_patch(struct patch *patch)
costate.not_new = 0;
costate.refresh_cache = 1;
if (checkout_entry(active_cache[pos],
costate.not_new = 0;
costate.refresh_cache = 1;
if (checkout_entry(active_cache[pos],
- &costate) ||
+ &costate,
+ NULL) ||
lstat(old_name, &st))
return -1;
}
lstat(old_name, &st))
return -1;
}
@@
-1951,9
+1965,11
@@
int main(int argc, char **argv)
if (fd < 0)
usage(apply_usage);
read_stdin = 0;
if (fd < 0)
usage(apply_usage);
read_stdin = 0;
+ set_default_whitespace_mode(whitespace_option);
apply_patch(fd, arg);
close(fd);
}
apply_patch(fd, arg);
close(fd);
}
+ set_default_whitespace_mode(whitespace_option);
if (read_stdin)
apply_patch(0, "<stdin>");
if (whitespace_error) {
if (read_stdin)
apply_patch(0, "<stdin>");
if (whitespace_error) {