Skip to contentSkip to conversation

is there a canonical doc about how to deal with whitespace issues?

DISCUSSION Robert P. J. Day 3 participants 4 messages Jun 8, 2018 – Jun 13, 2018

lore
Share & tools
lore
#0 lore raw

for one of my courses, i wanted to write a section about the various
techniques for dealing with whitespace issues in git, so i started making a list, things like:

- running "git diff --check"
- "git commit --cleanup=" possibilities
- config options like core.{eol,safecrlf,autocrlf}
- i'm sure there are client-side hooks that can be mentioned

etc, etc.

has anyone ever written a doc that collects these things in one
place? if not, i guess i have to write one.

rday

Signature · 7 lines
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
#1 lore raw
Quoted 9 lines · Robert P. J. Day

for one of my courses, i wanted to write a section about the various
techniques for dealing with whitespace issues in git, so i started making a list, things like:

- running "git diff --check"
- "git commit --cleanup=" possibilities
- config options like core.{eol,safecrlf,autocrlf}
- i'm sure there are client-side hooks that can be mentioned

Quoted 7 lines

etc, etc.

has anyone ever written a doc that collects these things in one
place? if not, i guess i have to write one.

rday

I don't know of a doc for whitespace issues, but the contributing guide on GitForWindows [1] recommends git rebase --whitespace=fix.

Thanks,
-Stolee

[1] https://github.com/git-for-windows/git/blob/master/CONTRIBUTING.md#polish-your-commits

#2 lore raw
Quoted 4 lines · Derrick Stolee
Quoted 2 lines · Robert P. J. Day

for one of my courses, i wanted to write a section about the various
techniques for dealing with whitespace issues in git, so i started

What do you mean by white space issues?
That in itself is a complex topic:
* There are 3 different modes to ignore white space changes:
- trailing whitespaces,
- conversion of tab to space and back
These two are caught by the default in 'git diff --check'
- any white space change
This is interesting to ignore in git-blame[1], but sometimes it is actually interesting.

[1] See also
https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html

Quoted 5 lines
Quoted 5 lines

making a list, things like:

- running "git diff --check"
- "git commit --cleanup=" possibilities
- config options like core.{eol,safecrlf,autocrlf}

This sounds more like line ending or cross platform issues than whitespaces (except .eol)

Quoted 1 line
Quoted 1 line

- i'm sure there are client-side hooks that can be mentioned

Personally I use the defaults when contributing to git.git and have an editor setting that removes trailing white spaces.

That has served me well so far; the only time I was bitten by white spaces is when sending patches using an email client other than git-send-email as the white spaces might get mangled there.

Is sending patches by email part of your course?

#3 lore raw
Quoted 9 lines · Stefan Beller
Quoted 5 lines · Derrick Stolee
Quoted 3 lines · Robert P. J. Day

for one of my courses, i wanted to write a section about the
various techniques for dealing with whitespace issues in git, so i started

What do you mean by white space issues?
That in itself is a complex topic:

i know ... it's not even clear that just dealing with EOL
standardization shouldn't be a topic all by itself.

Quoted 13 lines

* There are 3 different modes to ignore white space changes:
- trailing whitespaces,
- conversion of tab to space and back
These two are caught by the default in 'git diff --check'
- any white space change
This is interesting to ignore in git-blame[1], but sometimes it is actually interesting.

[1] See also
https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

making a list, things like:

- running "git diff --check"
- "git commit --cleanup=" possibilities
- config options like core.{eol,safecrlf,autocrlf}

This sounds more like line ending or cross platform issues than whitespaces (except .eol)

i just started a quick-and-dirty wiki page as a reference to things
that relate to whitespace:

http://crashcourse.ca/dokuwiki/doku.php?id=git_whitespace

it's not even *remotely* close to comprehensive, i just wanted to start making a list. feel free to make other suggestions as i keep adding to that page.

rday

Signature · 7 lines
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================