File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -1866,13 +1866,13 @@ static int match_fragment(struct image *img,
1866
1866
if (match_end && (preimage -> nr + try_lno != img -> nr ))
1867
1867
return 0 ;
1868
1868
} else if (ws_error_action == correct_ws_error &&
1869
- (ws_rule & WS_BLANK_AT_EOF ) && match_end ) {
1869
+ (ws_rule & WS_BLANK_AT_EOF )) {
1870
1870
/*
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.
1876
1876
*/
1877
1877
preimage_limit = img -> nr - try_lno ;
1878
1878
} 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' '
330
330
test_cmp one expect
331
331
'
332
332
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
+
333
345
test_expect_success ' shrink file with tons of missing blanks at end of file' '
334
346
{ echo a; echo b; echo c; } >one &&
335
347
cp one no-blank-lines &&
You can’t perform that action at this time.
0 commit comments