git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: the war on trailing whitespace

From
Junio C Hamano <junkio@cox.net>
Date
Feb 27, 2006, 23:18 UTC
Message-ID
<7vhd6kxuea.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060227011832.78359f0a.akpm@osdl.org>
Andrew Morton <akpm@osdl.org> writes:
Show 5 quoted lines
> That's not a good reason.  People will discover that git has started
> shouting at them and they'll work out how to make it stop.
>
> The problem is getting C users to turn the check on, not in getting python
> users to turn it off.

This whitespace policy should be at least per-project (people working on both kernel and other things may have legitimate reason to want trailing whitespace in the other project), so we would need some configurability; the problem is *both*.

We could do one of two things, at least.
 - I modify the git-apply that is in the "next" branch further
   to make --whitespace=error the default, and push it out.  You
   convince people who feed things to you to update to *that*
   version or later.
 - I already have the added whitespace detection hook (a fixed
   one that actually matches what I use) shipped with git.  You
   convince people who feed things to you to update to *that*
   version or later, and to enable that hook.

I think you are arguing for the first one. I am reluctant to do so because it would not help by itself *anyway*. In any case you need to convince people who feed things to you to do something to prevent later changes fed to you from being contaminated with trailing whitespaces.

Having said that, I have a third solution, which consists of two patches that come on top of what are already in "next" branch:

 - apply: squelch excessive errors and --whitespace=error-all
 - apply --whitespace: configuration option.

With these, git-apply used by git-applymbox and git-am would refuse to apply a patch that adds trailing whitespaces, when the per-repository configuration is set like this:

        [apply]
                whitespace = error
(Alternatively,
	$ git repo-config apply.whitespace error
would set these lines there for you).
I think there are three kinds of git users.
 * Linus, you, and the kernel subsystem maintainers.  The
   whitespace policy with this version of git-apply (with the
   configuration option set to apply.whitespace=error) gives
   would help these people by enforcing the SubmittingPatches
   and your "perfect patch" requirements.
 * People who feed patches to the above people.  They are helped
   by enabling the pre-commit hook that comes with git to
   conform to the kernel whitespace policy -- they need to be
   educated to do so.
 * People outside of kernel community, using git in projects to
   which the kernel whitespace policy does not have any
   relevance.

While I do consider the kernel folks a lot more important customers than other users, I have to take flak from the third kind of users, and to them, authority by Linus or you does not weigh as much as the first two classes of people. Making the default to --whitespace=error means that you are making me justify this kernel project policy as something applicable to projects outside the kernel. That is simply not fair to me.

You have to convince people you work with to update to at least to this version anyway, so I do not think it is too much to ask from you, while you are at it, to tell the higher echelon folks to do:

	$ git repo-config apply.whitespace error

in their repositories (and/or set that in their templates so new repositories created with git-init-db would inherit it).

Previous: Andrew MortonNext: Peter Williams
Message 12 of 40 in “the war on trailing whitespace”
  1. Andrew MortonFeb 26, 2006
  2. Junio C HamanoFeb 26, 2006
  3. Andrew MortonFeb 26, 2006
  4. Linus TorvaldsFeb 26, 2006
  5. Andrew MortonFeb 26, 2006
  6. Linus TorvaldsFeb 26, 2006
  7. Dave JonesFeb 26, 2006
  8. Dave JonesFeb 26, 2006
  9. MIke GalbraithFeb 27, 2006
  10. Johannes SchindelinFeb 27, 2006
  11. Andrew MortonFeb 27, 2006
  12. Junio C HamanoFeb 27, 2006
  13. Peter WilliamsFeb 27, 2006
  14. Junio C HamanoFeb 28, 2006
  15. Andrew MortonFeb 27, 2006
  16. git-apply: war on whitespace -- finishing touches.Junio C Hamano, Feb 28, 2006
  17. 1/3 apply: squelch excessive errors and --whitespace=error-allJunio C Hamano, Feb 28, 2006
  18. 2/3 apply --whitespace: configuration option.Junio C Hamano, Feb 28, 2006
  19. Andreas EricssonFeb 28, 2006
  20. Junio C HamanoFeb 28, 2006
  21. Andreas EricssonFeb 28, 2006
  22. 3/3 git-apply --whitespace=nowarnJunio C Hamano, Feb 28, 2006
  23. A Large Angry SCMFeb 28, 2006
  24. Junio C HamanoFeb 28, 2006
  25. Adrien BeauFeb 27, 2006
  26. Andreas EricssonFeb 27, 2006
  27. Uwe ZeisbergerFeb 27, 2006
  28. Andreas EricssonFeb 27, 2006
  29. Peter HagervallFeb 27, 2006
  30. Johannes SchindelinFeb 27, 2006
  31. Randal L. SchwartzFeb 27, 2006
  32. Josef WeidendorferFeb 27, 2006
  33. Adrien BeauFeb 27, 2006
  34. Uwe ZeisbergerFeb 27, 2006
  35. Andreas EricssonFeb 27, 2006
  36. Johannes SchindelinFeb 27, 2006
  37. Junio C HamanoFeb 27, 2006
  38. apply --whitespace fixes and enhancements.Junio C Hamano, Feb 27, 2006
  39. Junio C HamanoFeb 26, 2006
  40. Sam RavnborgFeb 26, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.