[PATCH] eol: fix missing trailing newlines in comitted files

Martin Geisler mg at aragost.com
Thu Jun 30 03:15:05 CDT 2011


Mads Kiilerich <mads at kiilerich.com> writes:

> Matt Mackall wrote, On 06/30/2011 12:39 AM:
>> On Thu, 2011-06-30 at 01:45 +0400, Stepan Koltsov wrote:
>>> # HG changeset patch
>>> # User Stepan Koltsov<stepancheg at yandex-team.ru>
>>> # Date 1309383716 -14400
>>> # Node ID 222e553fc1f59d83c01123c63dda918fd76f66ce
>>> # Parent  c64bd320e4f0a0bf36f64292900822e6f1f09a56
>>> eol: fix missing trailing newlines in comitted files
>>>
>>> Some text editors (Eclipse, for example) do not add trailing newlines,
>>> so diffs often contain annoying "\ No newline at the end of file".
>>> This patch to eol extension simply adds trailing newline on commit.
>> This strikes me as the wrong thing to do: it makes it impossible to
>> make a file with no trailing newline. As it happens, some people
>> actually don't want your proposed behavior:
>>
>> http://stackoverflow.com/questions/1050640/vim-disable-automatic-newline-at-end-of-file
>>
>> I think this issue is rather solidly in the domain of editor
>> configuration.
>
> Line endings in general is in the domain of editor configuration, but
> we have this extension anyway to provide a way to clean up after those
> who can't fix their editor configuration. The whole purpose of this
> extension is to ensure a specific type of line ending. If people don't
> want this then they should fix their .hgeol patterns or stop using the
> extension.

I agree with this -- Matt is right that people should configure their
editors in the first place, but this extension is for people who cannot
or wont do that.

> This change do thus in my opinion fit into the scope of the eol
> extension and could be moderately nice to have.
>
> It will however introduce a new invariant and cause some spurious
> diffs for existing users of the eol extension if it is enabled by
> default. I think it should be disabled by default and have an option
> in .hgeol for enabling it.

I also think we should include this functionality. Since people who use
the eol extension have already said "I cannot be bothered, please handle
line-endings for me", I think it is okay to turn this on by default.

-- 
Martin Geisler

aragost Trifork
Professional Mercurial support
http://mercurial.aragost.com/kick-start/


More information about the Mercurial-devel mailing list