trailing++;
check_old_for_crlf(patch, line, len);
if (!state->apply_in_reverse &&
- state->ws_error_action == correct_ws_error)
- check_whitespace(state, line, len, patch->ws_rule);
+ state->ws_error_action == correct_ws_error) {
+ const char *test_line = line;
+ int test_len = len;
+ if (*line == '\n') {
+ test_line = " \n";
+ test_len = 2;
+ }
+ check_whitespace(state, test_line, test_len,
+ patch->ws_rule);
+ }
break;
case '-':
if (!state->apply_in_reverse)
git config core.whitespace incomplete-line
'
+test_expect_success 'no incomplete context line (not an error)' '
+ test_when_finished "rm -f sample*-i patch patch-new target" &&
+ test_write_lines 1 2 3 "" 4 5 >sample-i &&
+ test_write_lines 1 2 3 "" 0 5 >sample2-i &&
+ cat sample-i >target &&
+ git add target &&
+ cat sample2-i >target &&
+ git diff-files -p target >patch &&
+ sed -e "s/^ $//" <patch >patch-new &&
+
+ cat sample-i >target &&
+ git apply --whitespace=fix <patch-new 2>error &&
+ test_cmp sample2-i target &&
+ test_must_be_empty error
+'
+
test_expect_success 'incomplete context line (not an error)' '
(test_write_lines 1 2 3 4 5 && printf 6) >sample-i &&
(test_write_lines 1 2 3 0 5 && printf 6) >sample2-i &&