aboutsummaryrefslogtreecommitdiff
path: root/Documentation/CodingGuidelines
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-04-01 01:57:46 +0200
committerJunio C Hamano <gitster@pobox.com>2026-03-31 20:43:13 -0700
commit55903dc87bee544c314706c509168afbbe14d262 (patch)
tree8d7448b46bfdb079253ae1800b31a24414f8ce65 /Documentation/CodingGuidelines
parente104e63a813cf581156b5daa7d86835e1030648a (diff)
downloadgit-55903dc87bee544c314706c509168afbbe14d262.tar.xz
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>
Diffstat (limited to 'Documentation/CodingGuidelines')
-rw-r--r--Documentation/CodingGuidelines12
1 files changed, 12 insertions, 0 deletions
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index b8670751f5..4992e52093 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -668,6 +668,18 @@ For C programs:
unsigned other_field:1;
unsigned field_with_longer_name:1;
+ - When a function `F` accepts flags, those flags should be defined as `enum
+ F_flags`. Individual flag definitions should start with `F` and be in
+ all-uppercase letters. Flag values should be represented via bit shifts.
+ E.g.
+
+ enum frobnicate_flags {
+ FROBNICATE_FOO = (1 << 0),
+ FROBNICATE_BAR = (1 << 1),
+ };
+
+ int frobnicate(enum frobnicate_flags flags);
+
- Array names should be named in the singular form if the individual items are
subject of use. E.g.: