CodingGuidelines: document our style for flags

We have recently iterated a bit on our style for flags. Document this. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Apr 1, 2026 at 01:57 UTC 55903dc87bee544c314706c509168afbbe14d262
1 file changed +12
Documentation/CodingGuidelines
+12
@@ -668,6 +668,18 @@ For C programs:
668 unsigned other_field:1;
669 unsigned field_with_longer_name:1;
670
671 + - When a function `F` accepts flags, those flags should be defined as `enum
672 + F_flags`. Individual flag definitions should start with `F` and be in
673 + all-uppercase letters. Flag values should be represented via bit shifts.
674 + E.g.
675 +
676 + enum frobnicate_flags {
677 + FROBNICATE_FOO = (1 << 0),
678 + FROBNICATE_BAR = (1 << 1),
679 + };
680 +
681 + int frobnicate(enum frobnicate_flags flags);
682 +
683 - Array names should be named in the singular form if the individual items are
684 subject of use. E.g.:
685