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

Re: [PATCH 3/5] Unify whitespace checking

From
Wincent Colaiuta <win@wincent.com>
Date
Dec 14, 2007, 07:36 UTC
Message-ID
<85B8B116-78F6-4D37-A9DB-30EECAB97956@wincent.com>
In-Reply-To
<7vd4taywfw.fsf@gitster.siamese.dyndns.org>
El 14/12/2007, a las 1:03, Junio C Hamano escribió:
Show 6 quoted lines
>> -	git diff --check | grep "space before tab"
>> +	git diff --check | grep "Space in indent is followed by a tab"
>>
> Hmph.  I think with the multiple detection this rewording would make  
> the
> error message very long to read.  Was the rewording really necessary?

Well, that wording came from builtin-apply.c so it wasn't really a "re- wording" but an extraction. The other string comes from "diff.c". So I had to pick one of them in unifying them and basically the one from builtin-apply.c won because it was the site where I extracted from first. So basically it was arbitrary.

If I were to actually *re-word* the message I think something like this would be the compromise between clarity and conciseness:

"space before tab in indent"

And in the same spirit, the other two strings extracted from builtin- apply.c into the new whitespace_error_string() function:

"Adds trailing whitespace" "Indent more than 8 places with spaces"

Could be shortened to:

"trailing whitespace" (diff.c says "white space at end") "indent using spaces"

But I personally have no strong conviction about this, so I'm happy for it to be whatever you want.

Show 11 quoted lines
>> +/* If stream is non-NULL, emits the line after checking. */
>> +unsigned check_and_emit_line(const char *line, int len, unsigned  
>> ws_rule,
>> +                             FILE *stream, const char *set,
>> +                             const char *reset, const char *ws)
>> +{
>
> Honestly, I regretted suggesting this, fearing that it might make the
> checking too costly, but the code is clean, readable, and does not  
> look
> costly at all.  Nice job.

Thanks. The check_and_emit_line function itself is fairly clean internally (apart from the somewhat ugly parameter list, but that was mostly inherited from the emit_line_with_ws function which it replaces). It's the sites where check_and_emit_line is called that look a bit ugly, but those can hopefully be cleaned up at some point in the future.

Cheers, Wincent

Previous: Junio C HamanoNext: Jakub Narebski
Message 11 of 24 in “"diff --check" and whitespace enhancements”
  1. 0/5 "diff --check" and whitespace enhancementsWincent Colaiuta, Dec 13, 2007
  2. 1/5 "diff --check" should affect exit statusWincent Colaiuta, Dec 13, 2007
  3. 2/5 New version of pre-commit hookWincent Colaiuta, Dec 13, 2007
  4. 3/5 Unify whitespace checkingWincent Colaiuta, Dec 13, 2007
  5. 4/5 Make "diff --check" output match "git apply"Wincent Colaiuta, Dec 13, 2007
  6. 5/5 Add tests for "git diff --check" with core.whitespace optionsWincent Colaiuta, Dec 13, 2007
  7. Junio C HamanoDec 14, 2007
  8. Junio C HamanoDec 14, 2007
  9. Andreas EricssonDec 13, 2007
  10. Junio C HamanoDec 14, 2007
  11. Wincent ColaiutaDec 14, 2007
  12. Jakub NarebskiDec 14, 2007
  13. Wincent ColaiutaDec 14, 2007
  14. Jakub NarebskiDec 14, 2007
  15. Don't use the pager when running "git diff --check"Wincent Colaiuta, Dec 13, 2007
  16. Jeff KingDec 14, 2007
  17. Junio C HamanoDec 14, 2007
  18. Junio C HamanoDec 14, 2007
  19. Wincent ColaiutaDec 14, 2007
  20. Junio C HamanoDec 14, 2007
  21. Wincent ColaiutaDec 14, 2007
  22. Junio C HamanoDec 14, 2007
  23. Junio C HamanoDec 13, 2007
  24. Junio C HamanoDec 14, 2007

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.