Skip to content

Using core.whitespace fix in git #11412

Description

@gibfahn

We recommend using git config --global --add core.whitespace fix in doc/onboarding.md, but I can't find any mention of that setting in the git docs. There is a core.whitespace, but it doesn't seem to have a fix option. However, apply.whitespace does, see the apply docs.

I think what we need is git config --global --add apply.whitespace fix. Note that this only fixes whitespace when you apply a patch. Rebase has a whitespace option as well, but it's apparently incompatible with --interactive, so I'm not sure if we should use it.

We might also consider suggesting git config --global diff.wsErrorHighlight all, which makes git diff and git show highlight whitespace errors (see docs).

cc/ @Fishrock123 (from git blame)

Activity

  1. added
    metaIssues and PRs related to the general management of the project.
    on Feb 16, 2017
  2. Fishrock123 commented on Feb 16, 2017

    @Fishrock123
    Contributor

    I think you can also set these per-repo. Is it possible that .gitattributes or similar could store this?

    I do think it is worthwhile to still suggest people enable the whitespace fixer globally. Not sure about altering git diff, etc.

  3. gibfahn commented on Feb 16, 2017

    @gibfahn
    MemberAuthor

    @Fishrock123 what I'm saying is I don't think core.whitespace fix actually does anything, I think it's just a wrong option. I think the option should be apply.whitespace fix.

    I'm pretty sure this stuff has to go in .git/config if it's local, so I don't think we could store it.

  4. silverwind commented on Feb 17, 2017

    @silverwind
    Contributor

    Let's drop that recommendation, we already recommend --whitespace=fix when landing:

    https://github.com/nodejs/node/blob/master/COLLABORATOR_GUIDE.md#technical-howto

  5. silverwind commented on Feb 17, 2017

    @silverwind
    Contributor

    Regarding diff.wsErrorHighlight: I'm not sure we should make any more recommendations. There's a lot one could recommend for git, and most of these options are personal preference. For example, I auto-trim trailing whitespace in the editor, so it will never be visible in a diff.

  6. matkoniecz commented on Apr 16, 2017

    @matkoniecz
    Contributor

    I can confirm that option core.whitespace fix is not doing for an unpatched git. Given that it is not documented in https://git-scm.com/docs/git-config it is not surprising.

  7. matkoniecz commented on Apr 16, 2017

    @matkoniecz
    Contributor

    PR #12445 removes this misleading instruction

  8. mscdex commented on Apr 16, 2017

    @mscdex
    Contributor

    I think I'd rather just correct the option name rather than remove it. The less explicit parameters needed the better IMHO.

  9. matkoniecz commented on Apr 17, 2017

    @matkoniecz
    Contributor

    I think the option should be apply.whitespace fix.

    According to docs it is used only on applying patch. Is it useful/intended result of this instruction?

  10. addaleax commented on Apr 29, 2017

    @addaleax
    Member

    #12445 landed, I think this can be closed now. Feel free to re-open if I’m wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    metaIssues and PRs related to the general management of the project.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions