File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1866,13 +1866,13 @@ static int match_fragment(struct image *img,
18661866 if (match_end && (preimage -> nr + try_lno != img -> nr ))
18671867 return 0 ;
18681868 } else if (ws_error_action == correct_ws_error &&
1869- (ws_rule & WS_BLANK_AT_EOF ) && match_end ) {
1869+ (ws_rule & WS_BLANK_AT_EOF )) {
18701870 /*
1871- * This hunk that matches at the end extends beyond
1872- * the end of img, and we are removing blank lines
1873- * at the end of the file. This many lines from the
1874- * beginning of the preimage must match with img, and
1875- * the remainder of the preimage must be blank.
1871+ * This hunk extends beyond the end of img, and we are
1872+ * removing blank lines at the end of the file. This
1873+ * many lines from the beginning of the preimage must
1874+ * match with img, and the remainder of the preimage
1875+ * must be blank.
18761876 */
18771877 preimage_limit = img -> nr - try_lno ;
18781878 } else {
Original file line number Diff line number Diff line change @@ -330,6 +330,18 @@ test_expect_success 'two missing blank lines at end with --whitespace=fix' '
330330 test_cmp one expect
331331'
332332
333+ test_expect_success ' missing blank line at end, insert before end, --whitespace=fix' '
334+ { echo a; echo; } >one &&
335+ git add one &&
336+ { echo b; echo a; echo; } >one &&
337+ cp one expect &&
338+ git diff -- one >patch &&
339+ echo a >one &&
340+ test_must_fail git apply patch &&
341+ git apply --whitespace=fix patch &&
342+ test_cmp one expect
343+ '
344+
333345test_expect_success ' shrink file with tons of missing blanks at end of file' '
334346 { echo a; echo b; echo c; } >one &&
335347 cp one no-blank-lines &&
You can’t perform that action at this time.
0 commit comments