Re: [PATCH 1/3] Documentation: clarify indentation style for C preprocessor directives
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 25, 2024, 05:06 UTC
- Message-ID
- <xmqq1q3irrgk.fsf@gitster.g>
- In-Reply-To
- <xmqqv80uwxn2.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
> Patrick Steinhardt <ps@pks.im> writes: > >> There has recently been some discussion around how C preprocessor >> directives shall be indented [1]. This discussion was settled towards >> indenting after the hash by two spaces [2]. Document it as such. > > It was settled to have space after and not before the hash, but I do > not recall ever agreeing to two spaces. I prefer to increment by 1 > for each level instead to keep the whole thing less distracting > while carrying meaningful information.
Using the indentation consistently is a good thing I do not object to.
Among our existing header and source files (excluding compat/ that is full of borrowed sources), scanning output from
$ git grep -e '# *' '*.[ch]' ':!compat/'
tells me that
- builtin/gc.c (3 lines) - git-compat-util.h (52 lines) - trace.c (2 lines) - wildmatch.c (6 lines)
use one space indent after '#' per level, while
- hash.h (10 lines, inconsistently 2 uses 1 per level) - thread-utils.c (8 lines)
use two space indent after '#' per level.
In compat/ directory, only compat/nedmalloc uses 2-space indent. There in the hierarchy are so many files we borrowed from GNU, whose coding style sticks to one-space indent.