projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix test case for some sed
[git.git]
/
apply.c
diff --git
a/apply.c
b/apply.c
index
af9900f
..
c369966
100644
(file)
--- a/
apply.c
+++ b/
apply.c
@@
-32,7
+32,7
@@
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,
static enum whitespace_eol {
nowarn_whitespace,
@@
-75,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
@@
-1223,6
+1232,14
@@
static int apply_one_fragment(struct buffer_desc *desc, struct fragment *frag)
size -= len;
}
size -= len;
}
+#ifdef NO_ACCURATE_DIFF
+ if (oldsize > 0 && old[oldsize - 1] == '\n' &&
+ newsize > 0 && new[newsize - 1] == '\n') {
+ oldsize--;
+ newsize--;
+ }
+#endif
+
offset = find_offset(buf, desc->size, old, oldsize, frag->newpos);
if (offset >= 0) {
int diff = newsize - oldsize;
offset = find_offset(buf, desc->size, old, oldsize, frag->newpos);
if (offset >= 0) {
int diff = newsize - oldsize;
@@
-1390,7
+1407,7
@@
static int check_patch(struct patch *patch)
return -1;
}
return -1;
}
- changed = ce_match_stat(active_cache[pos], &st);
+ changed = ce_match_stat(active_cache[pos], &st
, 1
);
if (changed)
return error("%s: does not match index",
old_name);
if (changed)
return error("%s: does not match index",
old_name);
@@
-1947,9
+1964,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) {