Merge branch 'jc/whitespace-incomplete-line'
Fix whitespace correction for new-style empty context lines. * jc/whitespace-incomplete-line: apply: fix new-style empty context line triggering incomplete-line checkmaint
commit
55d867c547
12
apply.c
12
apply.c
|
|
@ -1840,8 +1840,16 @@ static int parse_fragment(struct apply_state *state,
|
||||||
trailing++;
|
trailing++;
|
||||||
check_old_for_crlf(patch, line, len);
|
check_old_for_crlf(patch, line, len);
|
||||||
if (!state->apply_in_reverse &&
|
if (!state->apply_in_reverse &&
|
||||||
state->ws_error_action == correct_ws_error)
|
state->ws_error_action == correct_ws_error) {
|
||||||
check_whitespace(state, line, len, patch->ws_rule);
|
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;
|
break;
|
||||||
case '-':
|
case '-':
|
||||||
if (!state->apply_in_reverse)
|
if (!state->apply_in_reverse)
|
||||||
|
|
|
||||||
|
|
@ -561,6 +561,22 @@ test_expect_success 'check incomplete lines (setup)' '
|
||||||
git config core.whitespace incomplete-line
|
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_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 4 5 && printf 6) >sample-i &&
|
||||||
(test_write_lines 1 2 3 0 5 && printf 6) >sample2-i &&
|
(test_write_lines 1 2 3 0 5 && printf 6) >sample2-i &&
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue