[CCing David Symonds, because the same comment also applies to his patches.] Junio C Hamano wrote: > This introduces a new whitespace error type, "indent-with-non-tab". > The error is about starting a line with 8 or more SP, instead of > indenting it with a HT. > > This is not enabled by default, as some projects employ an > indenting policy to use only SPs and no HTs. > > The kernel folks and git contributors may want to enable this > detection with: > > [core] > whitespace = indent-with-non-tab This seems somewhat broken, whether a project uses tabs for indentation or not. Lines can still legitimately start with many spaces. Tab-based indentation should only use tabs to line up with other tabs, not with characters. (Unfortunately most editors get this wrong when indenting with tabs. I use spaces, not because I ideologically oppose tabs, but because I can't get any editor I want to use to do the right thing with tabs.) 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(". All the editors I know of use a tab; they just blindly replace a tab-width worth of spaces with a tab in initial indentation. That statement would normally appear indented in a function, so the continuation line should have tabs up to the indentation level of the fprintf, and then 8 spaces. An example more likely to appear at the start of the line, where this indent-with-non-tab heuristic would flag it: #define macro(arg1, arg2) macro_content \ more_macro_content Another example: some_type function_name(arg1, arg2, argred, argblue, argmore, argless) Again, the indentation should use spaces if it wants to line up after the open parenthesis, whether the project uses tabs or spaces for indentation. (Those examples may or may not match all coding styles; some just indent the continuation lines by a fixed number of tabs, and also treat the first line as a continuation line to keep the indentation consistent. Just presenting them as examples.) - Josh Triplett
Attachment:
signature.asc
Description: OpenPGP digital signature