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

Re: [PATCH 2/2] git-diff: complain about >=8 consecutive spaces in initial indent

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 14, 2007, 00:46 UTC
Message-ID
<7vabphr6w4.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<473A3552.3060907@freedesktop.org>
Josh Triplett <josh@freedesktop.org> writes:
Show 8 quoted lines
> My standard test case for this:
>
> fprintf("some very long string",
>         arguments);
>
> Type the first line, and press enter.  A good editor should indent to
> the open parenthesis.  However, it should not use a tab, because it
> needs to match up with the length of "fprintf(".

Sorry, I do not want to go into ideology or be anal, but I have to disagree. Tab width is 8 spaces (in the kernel and git), so "fprintf(" from the beginning of the line and an HT at the beginning of the line have the same width.

Your project may have different conventions. Then you do not have to use that option to check for 8 or more leading spaces.

And honestly, I think responding to that by saying "but somebody can have tab width that is not 8" is irrelevant. Somebody else can even use a non-proportional font to print it, so your 8 spaces and "fprintf(" won't line up ANYWAY.

If you REALLY want to be anal, then the rules to follow would be:

 - Do not assume you know the width of a HT, other than that the
   same number of HT at the beginning of two lines indent to the
   same distance from the left margin, and more of them indent
   deeper;
 - Do not assume the text will be printed in monospace;
which leads to:
 - Indent with the same number of HT from the beginning of
   lines.  Go deeper with one more HT, go shallower with one
   less HT.
 - Start the continuation line with the same number of HT to
   indent but DO NOT BOTHER aligning.  There is no alignment,
   period.

I happen to choose to be less anal, and accept 8 space HT _and_ monospace font. So "complaining at >=8 SP at the beginning" makes perfect sense, so does a corresponding patch to convert such runs of SPs to HTs with "git-apply --whitespace=fix" (which should require an option to be enabled, and the is not here yet) when applying a patch.

Previous: Josh TriplettNext: David Symonds
Message 4 of 12 in “War on whitespace: first, a bit of retreat.”
  1. 1/2 War on whitespace: first, a bit of retreat.Junio C Hamano, Nov 2, 2007
  2. 2/2 git-diff: complain about >=8 consecutive spaces in initial indentJunio C Hamano, Nov 2, 2007
  3. Josh TriplettNov 13, 2007
  4. Junio C HamanoNov 14, 2007
  5. David SymondsNov 2, 2007
  6. Andreas EricssonNov 2, 2007
  7. David SymondsNov 2, 2007
  8. Jakub NarebskiNov 2, 2007
  9. David SymondsNov 2, 2007
  10. David SymondsNov 2, 2007
  11. J. Bruce FieldsNov 2, 2007
  12. Junio C HamanoNov 3, 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.