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

Re: [PATCH] Add gitattributes file making whitespace checking pickier

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 10, 2008, 11:31 UTC
Message-ID
<200802101231.16847.jnareb@gmail.com>
In-Reply-To
<7v8x1t5uk1.fsf@gitster.siamese.dyndns.org>
Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>>> *.py whitespace=!indent,trail,space
>>> *.el whitespace=!indent,trail,space

Emacs Lisp is (like Perl, and contrary to Python) whitespace agnostic, so here you just agree on historical usage. In this case the same should IMHO be done for gitweb/gitweb.perl in main .gitattributes.

:<: checks contrib/emacs/git.el :>:

Hmmm... it looks like git.el uses only spaces, both for indent and for align, with some spurious TABS happening.

If you allow this, couldn't you allow also for the gitweb.perl?
Show 8 quoted lines
>>> fast-import/git-p4 whitespace=!indent,trail,space
>>
>> I would also exclude gitweb/gitweb.perl
> 
> Why?
> 
> As far as I can tell, Perl does not use Python/Elisp "indents
> are all whitespace" rule and neither does the script.

Elisp is also whitespace agnostic, but like in Perl it can contain here-docs, and heredoc-like docstring; I'm not sure about whitespace rules for that.

Show 5 quoted lines
> It also happens that I do not personally believe in "alignment
> with spaces" argument.  If you accept W and a SP occupy the same
> horizontal space (which "alignment with spaces" assume), I do
> not think it is unreasonable to accept HT goes to the next
> column that is multiple of 8 places.
 
My argument is that when you change tab-width (and basic-offset), with
"tabs for indent, spaces for align" you don't have source get out of 
align. And not everybody uses large screens, and large resolution.

Besides there is also purely theoretical argument of consistency. When using tabs also for align, it is in prectice align with tabs _and spaces_, e.g.:

------>|if (expression || ------>|____expression) {

or

------>|print "something" . ------>|______"something";

or

------>|$date{'mday-time'} = sprintf "%d %s %02d:%02d", ------>|------>|------>|_____$mday, $months[$mon], $hour ,$min;

where leading tab is marked as "------>|", and leading space as "_".

The argument for using tabs for align is that it is easy to check programatically for those kind of whitespace errors, and that editors do that. But lacking tools or misconfigured tools shouldn't IMHO be cause of selecting a coding style / choosing a policy.

-- 
Jakub Narebski
Poland
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 22 in “Add gitattributes file making whitespace checking pickier”
  1. Add gitattributes file making whitespace checking pickierJ. Bruce Fields, Feb 9, 2008
  2. Daniel BarkalowFeb 9, 2008
  3. J. Bruce FieldsFeb 9, 2008
  4. J. Bruce FieldsFeb 9, 2008
  5. Jakub NarebskiFeb 9, 2008
  6. J. Bruce FieldsFeb 9, 2008
  7. Jakub NarebskiFeb 9, 2008
  8. J. Bruce FieldsFeb 9, 2008
  9. Junio C HamanoFeb 9, 2008
  10. J. Bruce FieldsFeb 9, 2008
  11. Jakub NarebskiFeb 9, 2008
  12. Junio C HamanoFeb 10, 2008
  13. Jakub NarebskiFeb 10, 2008
  14. Junio C HamanoFeb 10, 2008
  15. Add gitattributes file making whitespace checking pickierJunio C Hamano, Feb 10, 2008
  16. J. Bruce FieldsFeb 10, 2008
  17. Daniel BarkalowFeb 10, 2008
  18. Junio C HamanoFeb 10, 2008
  19. Daniel BarkalowFeb 10, 2008
  20. Junio C HamanoFeb 11, 2008
  21. Brian DowningFeb 12, 2008
  22. Junio C HamanoFeb 12, 2008

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.