From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:21
We had quite inconsistent handing of patches that add new blank lines at
the end of file, and this miniseries is about fixing it.
Patch 1 is a fix to an ancient bug introduced by v1.5.5-rc0~156^2~11.
Patch 2 fixes a bug that is even older---I suspect it dates back to the
very first change that introduced the feature, but I did not bother to
dig.
Patch 4 (Patch 3 is a preliminary refactoring used by it) is about the
discrepancy between "--whitespace=fix" and "--whitespace=warn". The
blank-at-eof error was silently fixed but never diagnosed, which has
been one of the long-standing itch of mine to fix.
Patch 5 corrects the definition of blank-at-eof. If a patch adds an
non-empty line that consists solely of whitespaces at the end of file, we
should diagnose and strip it just line a new empty line. After all, both
are blank lines.
Patch 6 is a simple code reduction I noticed while preparing this series;
it can be a standalone patch, but it is obvious enough to be here.
Patches 7 and 8 address "git diff --check", which had roughly the same
logic as the --whitespace=fix. It shared the same problems the earlier
parts of the series fixed for "git apply".
Patch 9 is about "diff --color" to paint blank-at-eof as error, which we
did not do so far because it was too cumbersome. This has been another
one of the long-standing itch of mine to fix.
The series applies to v1.6.0.6-87-g82d97da; merging the result to 'master'
needs some conflict resolution.
1 apply --whitespace=fix: fix handling of blank lines at the eof
2 apply --whitespace=fix: detect new blank lines at eof correctly
3 apply.c: split check_whitespace() into two
4 apply --whitespace=warn/error: diagnose blank at EOF
5 apply --whitespace: warn blank but not necessarily empty lines at EOF
6 diff.c: the builtin_diff() deals with only two-file comparison
7 diff --whitespace=warn/error: obey blank-at-eof
8 diff --whitespace=warn/error: fix blank-at-eof check
9 diff --color: color blank-at-eof
Documentation/config.txt | 2 +
builtin-apply.c | 61 +++++++++++++++-------
cache.h | 3 +-
diff.c | 119 +++++++++++++++++++++++++++++---------------
t/t4015-diff-whitespace.sh | 11 +++-
t/t4019-diff-wserror.sh | 11 ++++-
t/t4124-apply-ws-rule.sh | 80 +++++++++++++++++++++++++++++
ws.c | 6 ++
8 files changed, 230 insertions(+), 63 deletions(-)
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:21
The command tries to strip blank lines at the end of the file added by a
patch. However, if the original ends with blank lines, often the patch
hunk ends like this:
@@ -l,5 +m,7 @@$
_context$
_context$
-deleted$
+$
+$
+$
_$
_$
where _ stands for SP and $ shows a end-of-line. This example patch adds
three trailing blank lines, but the code fails to notice it, because it
only pays attention to added blank lines at the very end of the hunk. In
this example, the three added blank lines do not appear textually at the
end in the patch, even though you can see that they are indeed added at
the end, if you rearrange the diff like this:
@@ -l,5 +m,7 @@$
_context$
_context$
-deleted$
_$
_$
+$
+$
+$
Fix this by not resetting the number of (candidate) added blank lines at
the end when the loop sees a context line that is empty.
Signed-off-by: Junio C Hamano <redacted>
---
builtin-apply.c | 6 ++++++
t/t4124-apply-ws-rule.sh | 12 ++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)
@@ -177,4 +177,16 @@ test_expect_success 'blank at EOF with --whitespace=fix (2)' 'test_cmpexpectone'+test_expect_success'blank at EOF with --whitespace=fix (3)''+{echoa;echob;echo;}>one&&+gitaddone&&+{echoa;echoc;echo;}>expect&&+{catexpect;echo;echo;}>one&&+gitdiff--one>patch&&++gitcheckoutone&&+gitapply--whitespace=fixpatch&&+test_cmpexpectone+'+ test_done
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:21
"git apply" strips new blank lines at EOF under --whitespace=fix option,
but neigher --whitespace=warn nor --whitespace=error paid any attention to
these errors.
Introduce a new whitespace error class, blank-at-eof, to make the
whitespace error handling more consistent.
The patch adds a new "linenr" field to the struct fragment in order to
record which line the hunk started in the input file, but this is needed
solely for reporting purposes. The detection of this class of whitespace
errors cannot be done while parsing a patch like we do for all the other
classes of whitespace errors. It instead has to wait until we find where
to apply the hunk, but at that point, we do not have an access to the
original line number in the input file anymore, hence the new field.
Depending on your point of view, this may be a bugfix that makes warn and
error in line with fix. Or you could call it a new feature. The line
between them is somewhat fuzzy in this case.
Strictly speaking, triggering more errors than before is a change in
behaviour that is not backward compatible, even though the reason for the
change is because the code was not checking for an error that it should
have. People who do not want added blank lines at EOF to trigger an error
can disable the new error class.
Signed-off-by: Junio C Hamano <redacted>
---
Documentation/config.txt | 2 ++
builtin-apply.c | 27 ++++++++++++++++++---------
cache.h | 3 ++-
t/t4124-apply-ws-rule.sh | 26 ++++++++++++++++++++++++++
ws.c | 6 ++++++
5 files changed, 54 insertions(+), 10 deletions(-)
@@ -389,6 +389,8 @@ core.whitespace:: error (enabled by default). * `indent-with-non-tab` treats a line that is indented with 8 or more space characters as an error (not enabled by default).+* `blank-at-eof` treats blank lines added at the end of file as an error+ (enabled by default). * `cr-at-eol` treats a carriage-return at the end of line as part of the line terminator, i.e. with it, `trailing-space` does not trigger if the character before such a carriage-return
@@ -126,6 +126,7 @@ struct fragment {constchar*patch;intsize;intrejected;+intlinenr;structfragment*next;};
@@ -1193,6 +1194,7 @@ static int parse_single_patch(char *line, unsigned long size, struct patch *patcintlen;fragment=xcalloc(1,sizeof(*fragment));+fragment->linenr=linenr;len=parse_fragment(line,size,patch,fragment);if(len<=0)die("corrupt patch at line %d",linenr);
@@ -2079,17 +2081,24 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,}if(applied_pos>=0){-if(ws_error_action==correct_ws_error&&-new_blank_lines_at_end&&-preimage.nr+applied_pos==img->nr){+if(new_blank_lines_at_end&&+preimage.nr+applied_pos==img->nr&&+(ws_rule&WS_BLANK_AT_EOF)&&+ws_error_action!=nowarn_ws_error){+record_ws_error(WS_BLANK_AT_EOF,"+",1,frag->linenr);+if(ws_error_action==correct_ws_error){+while(new_blank_lines_at_end--)+remove_last_line(&postimage);+}/*-*Ifthepatchapplicationaddsblanklines-*attheend,andifthepatchappliesatthe-*endoftheimage,removethoseaddedblank-*lines.+*Wewouldwanttopreventwrite_out_results()+*fromtakingplaceinapply_patch()thatfollows+*thecallchainledushere,whichis:+*apply_patch->check_patch_list->check_patch->+*apply_data->apply_fragments->apply_one_fragment*/-while(new_blank_lines_at_end--)-remove_last_line(&postimage);+if(ws_error_action==die_on_ws_error)+apply=0;}/*
@@ -189,4 +189,30 @@ test_expect_success 'blank at EOF with --whitespace=fix (3)' 'test_cmpexpectone'+test_expect_success'blank at EOF with --whitespace=warn''+{echoa;echob;echoc;}>one&&+gitaddone&&+echo>>one&&+catone>expect&&+gitdiff--one>patch&&++gitcheckoutone&&+gitapply--whitespace=warnpatch2>error&&+test_cmpexpectone&&+grep"new blank line at EOF"error+'++test_expect_success'blank at EOF with --whitespace=error''+{echoa;echob;echoc;}>one&&+gitaddone&&+catone>expect&&+echo>>one&&+gitdiff--one>patch&&++gitcheckoutone&&+test_must_failgitapply--whitespace=errorpatch2>error&&+test_cmpexpectone&&+grep"new blank line at EOF"error+'+ test_done
@@ -113,6 +114,11 @@ char *whitespace_error_string(unsigned ws)strbuf_addstr(&err,", ");strbuf_addstr(&err,"indent with spaces");}+if(ws&WS_BLANK_AT_EOF){+if(err.len)+strbuf_addstr(&err,", ");+strbuf_addstr(&err,"new blank line at EOF");+}returnstrbuf_detach(&err,NULL);}
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:21
b94f2ed (builtin-apply.c: make it more line oriented, 2008-01-26) broke
the logic used to detect if a hunk adds blank lines at the end of the
file. With the new code after that commit:
- img holds the contents of the file that the hunk is being applied to;
- preimage has the lines the hunk expects to be in img; and
- postimage has the lines the hunk wants to update the part in img that
corresponds to preimage with.
and we need to compare if the last line of preimage (not postimage)
matches the last line of img to see if the hunk applies at the end of the
file.
Signed-off-by: Junio C Hamano <redacted>
---
builtin-apply.c | 2 +-
t/t4124-apply-ws-rule.sh | 29 +++++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletions(-)
@@ -148,4 +148,33 @@ dodonedone++test_expect_success'blank at EOF with --whitespace=fix (1)''+:thesecanfaildependingonwhatwedidbefore+gitconfig--unsetcore.whitespace+rm-f.gitattributes++{echoa;echob;echoc;}>one&&+gitaddone&&+{echoa;echob;echoc;}>expect&&+{catexpect;echo;}>one&&+gitdiff--one>patch&&++gitcheckoutone&&+gitapply--whitespace=fixpatch&&+test_cmpexpectone+'++test_expect_success'blank at EOF with --whitespace=fix (2)''+{echoa;echob;echoc;}>one&&+gitaddone&&+{echoa;echoc;}>expect&&+{catexpect;echo;echo;}>one&&+gitdiff--one>patch&&++gitcheckoutone&&+gitapply--whitespace=fixpatch&&+test_cmpexpectone+'+ test_done
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:21
This splits the logic to record the presence of whitespace errors out of
the check_whitespace() function, which checks and then records. The new
function, record_ws_error(), can be used by the blank-at-eof check that
does not use ws_check() logic to report its findings in the same output
format.
Signed-off-by: Junio C Hamano <redacted>
---
builtin-apply.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:21
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 <redacted>
---
builtin-apply.c | 6 ++++--
t/t4124-apply-ws-rule.sh | 13 +++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
@@ -215,4 +215,17 @@ test_expect_success 'blank at EOF with --whitespace=error' 'grep"new blank line at EOF"error'+test_expect_success'blank but not empty at EOF''+{echoa;echob;echoc;}>one&&+gitaddone&&+echo" ">>one&&+catone>expect&&+gitdiff--one>patch&&++gitcheckoutone&&+gitapply--whitespace=warnpatch2>error&&+test_cmpexpectone&&+grep"new blank line at EOF"error+'+ test_done
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:21
The "diff --check" code used to conflate trailing-space whitespace error
class with this, but now we have a proper separate error class, we should
check it under blank-at-eof, not trailing-space.
The whitespace error is not about _having_ blank lines at end, but about
adding _new_ blank lines. To keep the message consistent with what is
given by "git apply", call whitespace_error_string() to generate it,
instead of using a hardcoded custom message.
Signed-off-by: Junio C Hamano <redacted>
---
diff.c | 10 +++++++---
t/t4015-diff-whitespace.sh | 4 ++--
t/t4019-diff-wserror.sh | 2 +-
3 files changed, 10 insertions(+), 6 deletions(-)
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:21
Since the coloring logic processed the patch output one line at a time, we
couldn't easily color code the new blank lines at the end of file.
Reuse the adds_blank_at_eof() function to find where the runs of such
blank lines start, keep track of the line number in the preimage while
processing the patch output one line at a time, and paint the new blank
lines that appear after that line to implement this.
Signed-off-by: Junio C Hamano <redacted>
---
diff.c | 37 +++++++++++++++++++++++++++----------
t/t4019-diff-wserror.sh | 9 +++++++++
2 files changed, 36 insertions(+), 10 deletions(-)
@@ -547,6 +549,12 @@ static void emit_add_line(const char *reset, struct emit_callback *ecbdata, consif(!*ws)emit_line(ecbdata->file,set,reset,line,len);+elseif((ecbdata->ws_rule&WS_BLANK_AT_EOF)&&+ecbdata->blank_at_eof&&+(ecbdata->blank_at_eof<=ecbdata->lno_in_preimage)&&+ws_blank_line(line+1,len-1,ecbdata->ws_rule))+/* Blank line at EOF */+emit_line(ecbdata->file,ws,reset,line,len);else{/* Emit just the prefix, then the rest. */emit_line(ecbdata->file,set,reset,line,1);
@@ -573,9 +581,16 @@ static unsigned long sane_truncate_line(struct emit_callback *ecb, char *line, ureturnallot-l;}+staticintfind_preimage_lno(constchar*line)+{+char*p=strchr(line,'-');+if(!p)+return0;/* should not happen */+returnstrtol(p+1,NULL,10);+}+staticvoidfn_out_consume(void*priv,char*line,unsignedlonglen){-intcolor;structemit_callback*ecbdata=priv;constchar*meta=diff_get_color(ecbdata->color_diff,DIFF_METAINFO);constchar*plain=diff_get_color(ecbdata->color_diff,DIFF_PLAIN);
@@ -190,4 +190,13 @@ test_expect_success 'do not color trailing cr in context' ''+test_expect_success'color new trailing blank lines''+{echoa;echob;echo;echo;}>x&&+gitaddx&&+{echoa;echo;echo;echo;echo;}>x&&+gitdiff--colorx>output&&+cnt=$(grep"${blue_grep}"output|wc-l)&&+test$cnt=2+'+ test_done
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:21
The combined diff is implemented in combine_diff() and fn_out_consume()
codepath never has to deal with anything but two-file comparison.
Drop nparents from the emit_callback structure and simplify the code.
Signed-off-by: Junio C Hamano <redacted>
---
diff.c | 32 +++++++++-----------------------
1 files changed, 9 insertions(+), 23 deletions(-)
@@ -598,13 +596,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)ecbdata->label_path[0]=ecbdata->label_path[1]=NULL;}-/* This is not really necessary for now because-*thiscodepathonlydealswithtwo-waydiffs.-*/-for(i=0;i<len&&line[i]=='@';i++)-;-if(2<=i&&i<len&&line[i]==' '){-ecbdata->nparents=i-1;+if(line[0]=='@'){len=sane_truncate_line(ecbdata,line,len);emit_line(ecbdata->file,diff_get_color(ecbdata->color_diff,DIFF_FRAGINFO),
@@ -614,15 +606,12 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)return;}-if(len<ecbdata->nparents){+if(len<1){emit_line(ecbdata->file,reset,reset,line,len);return;}color=DIFF_PLAIN;-if(ecbdata->diff_words&&ecbdata->nparents!=1)-/* fall back to normal diff */-free_diff_words_data(ecbdata);if(ecbdata->diff_words){if(line[0]=='-'){diff_words_append(line,len,
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:21
The "diff --check" logic used to share the same issue as the one fixed for
"git apply" earlier in this series, in that a patch that adds new blank
lines at end could appear as
@@ -l,5 +m,7 @@$
_context$
_context$
-deleted$
+$
+$
+$
_$
_$
where _ stands for SP and $ shows a end-of-line. Instead of looking at
each line in the patch in the callback, simply count the blank lines from
the end in two versions, and notice the presence of new ones.
Signed-off-by: Junio C Hamano <redacted>
---
diff.c | 64 +++++++++++++++++++++++++++++++++-----------
t/t4015-diff-whitespace.sh | 7 +++++
2 files changed, 55 insertions(+), 16 deletions(-)
@@ -1437,6 +1430,44 @@ static const struct funcname_pattern_entry *diff_funcname_pattern(struct diff_fireturnNULL;}+staticintcount_trailing_blank(mmfile_t*mf,unsignedws_rule)+{+char*ptr=mf->ptr;+longsize=mf->size;+intcnt=0;++if(!size)+returncnt;+ptr+=size-1;/* pointing at the very end */+if(*ptr!='\n')+;/* incomplete line */+else+ptr--;/* skip the last LF */+while(mf->ptr<ptr){+char*prev_eol;+for(prev_eol=ptr;mf->ptr<=prev_eol;prev_eol--)+if(*prev_eol=='\n')+break;+if(!ws_blank_line(prev_eol+1,ptr-prev_eol,ws_rule))+break;+cnt++;+ptr=prev_eol-1;+}+returncnt;+}++staticintadds_blank_at_eof(mmfile_t*mf1,mmfile_t*mf2,unsignedws_rule)+{+intl1,l2,at;+l1=count_trailing_blank(mf1,ws_rule);+l2=count_trailing_blank(mf2,ws_rule);+if(l2<=l1)+return0;+/* starting where? */+at=count_lines(mf1->ptr,mf1->size);+return(at-l1)+1;/* the line number counts from 1 */+}+staticvoidbuiltin_diff(constchar*name_a,constchar*name_b,structdiff_filespec*one,
From: Johannes Sixt <hidden> Date: 2016-06-15 22:47:21
Junio C Hamano schrieb:
The command tries to strip blank lines at the end of the file added by a
patch. However, if the original ends with blank lines, often the patch
hunk ends like this:
@@ -l,5 +m,7 @@$
_context$
_context$
-deleted$
+$
+$
+$
_$
_$
where _ stands for SP and $ shows a end-of-line. This example patch adds
three trailing blank lines, but the code fails to notice it, because it
only pays attention to added blank lines at the very end of the hunk. In
this example, the three added blank lines do not appear textually at the
end in the patch, even though you can see that they are indeed added at
the end, if you rearrange the diff like this:
@@ -l,5 +m,7 @@$
_context$
_context$
-deleted$
_$
_$
+$
+$
+$
Fix this by not resetting the number of (candidate) added blank lines at
the end when the loop sees a context line that is empty.
After reading this explanation, I was worried that added blank lines that
are at the end of a patch but apply in the middle of a file would be
mis-attributed as blank lines at EOF. But appearently, they are not, i.e.
such added blank lines are not removed. Could you squash in this test case
that checks for this condition.
-- Hannes
@@ -189,4 +189,16 @@ test_expect_success 'blank at EOF with --whitespace=fix (3)' 'test_cmpexpectone'+test_expect_success'blank at end of hunk, not at EOF with --whitespace=fix''+{echoa;echob;echo;echo;echo;echo;echo;echod;}>one&&+gitaddone&&+{echoa;echoc;echo;echo;echo;echo;echo;echo;echod;}>expect&&+cpexpectone&&+gitdiff--one>patch&&++gitcheckoutone&&+gitapply--whitespace=fixpatch&&+test_cmpexpectone+'+ test_done
Patch 5 corrects the definition of blank-at-eof. If a patch adds an
non-empty line that consists solely of whitespaces at the end of file, we
should diagnose and strip it just line a new empty line. After all, both
are blank lines.
Thank you. Thank you, thank you. Thank you! And did I mention thank you?
Tested this out after cherry-picking:
3b5ef0e xutils: Fix xdl_recmatch() on incomplete lines
78ed710 xutils: Fix hashing an incomplete line with whitespaces at the end
It worked as nicely! I'm throwing away the --allow-whitelines-at-eof
patch! :D Converting a _real_ dirty whitespace branch into an 'almost'
whitespace policy compliant branch with validation of the diffs was
able to be done like so:
git diff -b DIRTY CLEAN
git diff DIRTY^ CLEAN > diff1
git diff CLEAN^ DIRTY > diff2
git diff -b diff1 diff2
I mention 'almost' above because unfortunately this type of conversion
leaves extra line-spaces at the end of some files that you might not want
to have in a whitespace policy.
While thinking about what appeared in:
http://article.gmane.org/gmane.comp.version-control.git/124138
Junio C Hamano <gitster <at> pobox.com> writes:
Bruno Haible <bruno <at> clisp.org> writes:
quoted
In some GNU projects, there are file types for which trailing spaces in a line
...
Currently the user has to turn off the 'trailing-space' whitespace attribute
in order for 'git diff --check' to not complain about such files. This has
the drawback that trailing spaces are not detected.
Very good problem description. Thanks.
I thought it might be interesting to throw this out there... What do you
think of an additional attribute value like
core.whitespace blank-at-eof-min-<some 0 to N #>
core.whitespace blank-at-eof-max-<some 0 to N #>
that could be read in when core.whitespace blank-at-eof is set.
If neither are present then use current. (No new eof blanks).
If min but not max is set then allow new blanks and ensure at least min.
If max but not min is set then only allow max blanks at eof.
If both then treat it as a boundary.
This could ensure a whitespace policy without the repository maintainer
having to correct this type of minutia and without having to nit-pick
contributors into submission.
Then perhaps diff could also recognize an in range blank-at-eof so a diff
using one of the ignore whitespace options would ignore eof whitelines
that are in range?
The series applies to v1.6.0.6-87-g82d97da; merging the result to 'master'
needs some conflict resolution.
Oh, I forgot all about that one. The suggestion does include two very
good points, one being "git apply" which I did, and the other being what I
completely forgot. Introduction of blank-at-eol and blank-at-eof, and
make trailing-space a convenience synonym that triggers both.
Thanks for a reminder. The following patch can come on top of the
series.
-- >8 --
Subject: core.whitespace: split trailing-space into blank-at-{eol,eof}
People who configured trailing-space depended on it to catch both extra
white space at the end of line, and extra blank lines at the end of file.
Earlier attempt to introduce only blank-at-eof gave them an escape hatch
to keep the old behaviour, but it is a regression until they explicitly
specify the new error class.
This introduces a blank-at-eol that only catches extra white space at the
end of line, and makes the traditional trailing-space a convenient synonym
to catch both blank-at-eol and blank-at-eof. This way, people who used
trailing-space continue to catch both classes of errors.
Signed-off-by: Junio C Hamano <redacted>
---
Documentation/config.txt | 5 ++++-
cache.h | 5 +++--
ws.c | 24 +++++++++++++++---------
3 files changed, 22 insertions(+), 12 deletions(-)
@@ -382,7 +382,7 @@ core.whitespace:: consider them as errors. You can prefix `-` to disable any of them (e.g. `-trailing-space`): +-* `trailing-space` treats trailing whitespaces at the end of the line+* `blank-at-eol` treats trailing whitespaces at the end of the line as an error (enabled by default). * `space-before-tab` treats a space character that appears immediately before a tab character in the initial indent part of the line as an
@@ -391,11 +391,14 @@ core.whitespace:: space characters as an error (not enabled by default). * `blank-at-eof` treats blank lines added at the end of file as an error (enabled by default).+* `trailing-space` is a short-hand to cover both `blank-at-eol` and+ `blank-at-eof`. * `cr-at-eol` treats a carriage-return at the end of line as part of the line terminator, i.e. with it, `trailing-space` does not trigger if the character before such a carriage-return is not a whitespace (not enabled by default).+ core.fsyncobjectfiles:: This boolean will enable 'fsync()' when writing object files. +
@@ -101,9 +102,19 @@ unsigned whitespace_rule(const char *pathname)char*whitespace_error_string(unsignedws){structstrbuferr;+strbuf_init(&err,0);-if(ws&WS_TRAILING_SPACE)+if((ws&WS_TRAILING_SPACE)==WS_TRAILING_SPACE)strbuf_addstr(&err,"trailing whitespace");+else{+if(ws&WS_BLANK_AT_EOL)+strbuf_addstr(&err,"trailing whitespace");+if(ws&WS_BLANK_AT_EOF){+if(err.len)+strbuf_addstr(&err,", ");+strbuf_addstr(&err,"new blank line at EOF");+}+}if(ws&WS_SPACE_BEFORE_TAB){if(err.len)strbuf_addstr(&err,", ");
@@ -114,11 +125,6 @@ char *whitespace_error_string(unsigned ws)strbuf_addstr(&err,", ");strbuf_addstr(&err,"indent with spaces");}-if(ws&WS_BLANK_AT_EOF){-if(err.len)-strbuf_addstr(&err,", ");-strbuf_addstr(&err,"new blank line at EOF");-}returnstrbuf_detach(&err,NULL);}
@@ -146,11 +152,11 @@ static unsigned ws_check_emit_1(const char *line, int len, unsigned ws_rule,}/* Check for trailing whitespace. */-if(ws_rule&WS_TRAILING_SPACE){+if(ws_rule&WS_BLANK_AT_EOL){for(i=len-1;i>=0;i--){if(isspace(line[i])){trailing_whitespace=i;-result|=WS_TRAILING_SPACE;+result|=WS_BLANK_AT_EOL;}elsebreak;
@@ -266,7 +272,7 @@ int ws_fix_copy(char *dst, const char *src, int len, unsigned ws_rule, int *erro/**Striptrailingwhitespace*/-if((ws_rule&WS_TRAILING_SPACE)&&+if((ws_rule&WS_BLANK_AT_EOL)&&(2<=len&&isspace(src[len-2]))){if(src[len-1]=='\n'){add_nl_to_tail=1;