Node: Using core.whitespace fix in git

Created on 16 Feb 2017  路  9Comments  路  Source: nodejs/node

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)

meta

Most helpful comment

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

All 9 comments

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.

@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.

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

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

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.

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.

PR #12445 removes this misleading instruction

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

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?

12445 landed, I think this can be closed now. Feel free to re-open if I鈥檓 wrong.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Brekmister picture Brekmister  路  3Comments

dfahlander picture dfahlander  路  3Comments

stevenvachon picture stevenvachon  路  3Comments

fanjunzhi picture fanjunzhi  路  3Comments

danialkhansari picture danialkhansari  路  3Comments