Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing white spaces #59755

Closed
serhiy-storchaka opened this issue Aug 3, 2012 · 14 comments
Closed

Trailing white spaces #59755

serhiy-storchaka opened this issue Aug 3, 2012 · 14 comments
Labels
type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 15550
Nosy @birkenfeld, @terryjreedy, @jcea, @pitrou, @ned-deily, @skrah, @cjerdonek, @serhiy-storchaka
Superseder
  • bpo-8912: make patchcheck should check the whitespace of .c/.h files
  • Files
  • libffi_trailing_whitespaces.diff
  • libmpdec_trailing_whitespaces.diff
  • c_trailing_whitespaces.diff
  • other_trailing_whitespaces.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2012-08-08.08:58:32.917>
    created_at = <Date 2012-08-03.15:40:15.243>
    labels = ['type-feature']
    title = 'Trailing white spaces'
    updated_at = <Date 2012-10-04.10:50:15.756>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2012-10-04.10:50:15.756>
    actor = 'jcea'
    assignee = 'none'
    closed = True
    closed_date = <Date 2012-08-08.08:58:32.917>
    closer = 'ned.deily'
    components = []
    creation = <Date 2012-08-03.15:40:15.243>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['26689', '26690', '26691', '26692']
    hgrepos = []
    issue_num = 15550
    keywords = ['patch']
    message_count = 14.0
    messages = ['167337', '167349', '167350', '167357', '167421', '167430', '167433', '167434', '167438', '167440', '167444', '167532', '167535', '167677']
    nosy_count = 8.0
    nosy_names = ['georg.brandl', 'terry.reedy', 'jcea', 'pitrou', 'ned.deily', 'skrah', 'chris.jerdonek', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '8912'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue15550'
    versions = ['Python 3.4']

    @serhiy-storchaka
    Copy link
    Member Author

    My editors are configured to remove trailing spaces (this is useful for removing artifacts of indentation). The flip side of this is that my patches sometimes contain unrelated trailing spaces fixes.

    Trailing spaces are not significant in any CPython source file, their presence I believe mistake. Easier once we remove all spaces and then prevent the appearance of new, than constantly face to unrelated changes. I'm not attaching a patch (it is too big, over 5 MB), anyone can create it by the following commands:

    hg status -cn | tr '\n' '\0' | xargs -0 sed -i -re 's/[ \t]+$//'
    

    It would be good if the Mercurial would had hook, which automatically remove trailing spaces or prohibit to commit patches that contain trailing spaces.

    @serhiy-storchaka serhiy-storchaka added the type-feature A feature request or enhancement label Aug 3, 2012
    @serhiy-storchaka
    Copy link
    Member Author

    Because CPython repository contains binary files too, they should be reverted:

    hg diff | sed -nre 's/^Binary file (.*) has changed/\1/p' | tr '\n' '\0' | xargs -0 hg revert
    

    @ned-deily
    Copy link
    Member

    There already is a hook in place for the main python.org repository that checks for and rejects changesets that include files with space issues:

    http://hg.python.org/hooks/file/bd04c6b37749/checkwhitespace.py

    You can add it to your local repo to check patches before they are pushed.

    @pitrou
    Copy link
    Member

    pitrou commented Aug 3, 2012

    Or you can use "make patchcheck" which will (hopefully) warn you of such issues.

    @cjerdonek
    Copy link
    Member

    There already is a hook in place for the main python.org repository that checks for and rejects changesets that include files with space issues:

    If there is already a hook, then why do some files have spurious white space (i.e. at the end of a line)? Is that because those issues were present prior to putting the hook in place?

    @pitrou
    Copy link
    Member

    pitrou commented Aug 4, 2012

    AFAIR the hook only applies to Python and reST files, not C files.
    I think Georg wrote it, perhaps he knows the reasons.

    @serhiy-storchaka
    Copy link
    Member Author

    There already is a hook in place for the main python.org repository that
    checks for and rejects changesets that include files with space issues:

    Now I understand why there is no problem with .py files. But there are a lot of
    other files (including .c and .h) with trailing whitespaces.

    @birkenfeld
    Copy link
    Member

    Well, I'm -0 on extending the hook to C files.

    @serhiy-storchaka
    Copy link
    Member Author

    I found a few files where trailing spaces are significant (patches, RTF, test data). Excluding them and three generated file (Unicode data, generating scripts should be smarter), I divided the remaining into several parts:

    1. the libffi library;
    2. the libmpdec library;
    3. other C sources;
    4. the rest of the files (mainly readme-like files and build scripts).

    @ned-deily
    Copy link
    Member

    -1 for making wholesale whitespace changes. It potentially makes merging harder for little benefit. Imported files from other projects should definitely not be touched. IMO, the only thing potentially worth considering is extending the existing hook to C files. I'm +0 on that myself.

    @skrah
    Copy link
    Mannequin

    skrah mannequin commented Aug 4, 2012

    I'm not against whitespace cleanup every now and then, but also -0
    on a hook for C files. I think that (for C) the annoyance of having
    a patch rejected because of trailing whitespace outweighs the
    overall benefit.

    @terryjreedy
    Copy link
    Member

    How is it more of a nuisance for C files than for .py files?
    Editor 'trim trailing' tools certainly don't care.

    @cjerdonek
    Copy link
    Member

    Out of curiosity, is there a mechanism to bypass the hook on a per-file basis, if necessary? FWIW, the WebKit open source project had a similar hook (for SVN) to prevent the inclusion of tabs in source files, and a custom SVN property was used to bypass the check on a per-file basis.

    @ned-deily
    Copy link
    Member

    Since we've established that python files are already covered by 'make patchcheck' and the hg checkin hook and that there does not appear to be much enthusiasm for extending the hook to C files or to wholesale whitespace cleanup, the remaining issue is whether to extend 'make patchcheck' for C files. And that is the subject of open bpo-8912. So I'm going to close this issue as a duplicate of that one and suggest further discussion take place there. As for a per-file bypass, I'm not aware of any nor of any need that has arisen so far for one.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants