git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 0/9] War on blank-at-eof

From
Thell Fowler <git@tbfowler.name>
Date
Sep 5, 2009, 21:28 UTC
Message-ID
<alpine.WNT.2.00.0909051534380.7040@GWNotebook>
In-Reply-To
<1252061718-11579-1-git-send-email-gitster@pobox.com>
On Fri, 4 Sep 2009, Junio C Hamano wrote:
Show 5 quoted lines
> 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:

Show 6 quoted lines
>Bruno Haible <bruno <at> clisp.org> writes:
>> 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.
>
-- 
Thell
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 14 in “War on blank-at-eof”
  1. 0/9 War on blank-at-eofJunio C Hamano, Sep 4, 2009
  2. 1/9 apply --whitespace=fix: fix handling of blank lines at the eofJunio C Hamano, Sep 4, 2009
  3. 2/9 apply --whitespace=fix: detect new blank lines at eof correctlyJunio C Hamano, Sep 4, 2009
  4. Johannes SixtSep 4, 2009
  5. Junio C HamanoSep 4, 2009
  6. 3/9 apply.c: split check_whitespace() into twoJunio C Hamano, Sep 4, 2009
  7. 4/9 apply --whitespace=warn/error: diagnose blank at EOFJunio C Hamano, Sep 4, 2009
  8. 5/9 apply --whitespace: warn blank but not necessarily empty lines at EOFJunio C Hamano, Sep 4, 2009
  9. 6/9 diff.c: the builtin_diff() deals with only two-file comparisonJunio C Hamano, Sep 4, 2009
  10. 7/9 diff --whitespace=warn/error: obey blank-at-eofJunio C Hamano, Sep 4, 2009
  11. 8/9 diff --whitespace=warn/error: fix blank-at-eof checkJunio C Hamano, Sep 4, 2009
  12. 9/9 diff --color: color blank-at-eofJunio C Hamano, Sep 4, 2009
  13. Thell FowlerSep 5, 2009
  14. Junio C HamanoSep 6, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.