summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 77b15bb)
raw | patch | inline | side by side (parent: 77b15bb)
author | Junio C Hamano <gitster@pobox.com> | |
Fri, 4 Sep 2009 09:25:57 +0000 (02:25 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 4 Sep 2009 18:50:26 +0000 (11:50 -0700) |
The whitespace error of adding blank lines at the end of file should
trigger if you added a non-empty line at the end, if the contents of the
line is full of whitespaces.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
trigger if you added a non-empty line at the end, if the contents of the
line is full of whitespaces.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-apply.c | patch | blob | history | |
t/t4124-apply-ws-rule.sh | patch | blob | history |
diff --git a/builtin-apply.c b/builtin-apply.c
index 37d3bc069b1618f81c14cf0c87d31a0f1a3b081c..6662cc438cf0602784c3039b1b146ed4c3fc53cc 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
is_blank_context = 1;
break;
case ' ':
- if (plen && patch[1] == '\n')
+ if (plen && (ws_rule & WS_BLANK_AT_EOF) &&
+ ws_blank_line(patch + 1, plen, ws_rule))
is_blank_context = 1;
case '-':
memcpy(old, patch + 1, plen);
(first == '+' ? 0 : LINE_COMMON));
new += added;
if (first == '+' &&
- added == 1 && new[-1] == '\n')
+ (ws_rule & WS_BLANK_AT_EOF) &&
+ ws_blank_line(patch + 1, plen, ws_rule))
added_blank_line = 1;
break;
case '@': case '\\':
index 3a77a9af87a15f9c73795afd7e27d1e29a92db32..778d45bc07b9de420ea7596655b5dbd99fc30194 100755 (executable)
--- a/t/t4124-apply-ws-rule.sh
+++ b/t/t4124-apply-ws-rule.sh
grep "new blank line at EOF" error
'
+test_expect_success 'blank but not empty at EOF' '
+ { echo a; echo b; echo c; } >one &&
+ git add one &&
+ echo " " >>one &&
+ cat one >expect &&
+ git diff -- one >patch &&
+
+ git checkout one &&
+ git apply --whitespace=warn patch 2>error &&
+ test_cmp expect one &&
+ grep "new blank line at EOF" error
+'
+
test_done