threads / discuss / 48674

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

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

## tl;dr

4 messages between Jun 8, 2018 and Jun 13, 2018.

replies: 3people: 3as markdown or json

Robert P. J. Day· Jun 8, 2018, 13:18 UTC · lore
  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
-- 
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================
Derrick Stolee· Jun 8, 2018, 17:15 UTC · re: Robert P. J. Day · lore

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

On 6/8/2018 9:18 AM, Robert P. J. Day wrote:
Show 16 quoted lines
>    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
>

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

Stefan Beller· Jun 11, 2018, 21:45 UTC · re: Derrick Stolee · lore

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

On Fri, Jun 8, 2018 at 10:15 AM Derrick Stolee <stolee@gmail.com> wrote:
>
> On 6/8/2018 9:18 AM, Robert P. J. Day wrote:
> >    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

Show 5 quoted 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'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?
Robert P. J. Day· Jun 13, 2018, 12:26 UTC · re: Stefan Beller · lore

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

On Mon, 11 Jun 2018, Stefan Beller wrote:
Show 9 quoted lines
> On Fri, Jun 8, 2018 at 10:15 AM Derrick Stolee <stolee@gmail.com> wrote:
> >
> > On 6/8/2018 9:18 AM, Robert P. J. Day wrote:
> > >    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.
Show 21 quoted 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
>
>
>
> > > 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
-- 
========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                  http://crashcourse.ca/dokuwiki

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

← back to recent threads