]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
clang-format: Add include sorting directives
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 28 Apr 2025 12:17:05 +0000 (14:17 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 30 Apr 2025 07:30:33 +0000 (09:30 +0200)
Let's make sure clang-format sorts includes according to our style
guide.

.clang-format

index 5377abc23ee744209295f435ec42383c015bc872..5d1bdc52ab889d6765bf4a6d280a86d66fa466c9 100644 (file)
@@ -107,6 +107,27 @@ ForEachMacros:
   - STRV_FOREACH
   - STRV_FOREACH_BACKWARDS
   - STRV_FOREACH_PAIR
+IncludeBlocks: Regroup
+IncludeCategories:
+  # "vmlinux.h" must always be included first in BPF programs before anything else.
+  - Regex:           '^"vmlinux.h"$'
+    Priority:        1
+  # <bpf/*.h> headers must be included after <linux/types.h> by design.
+  - Regex:           '^<bpf/.*\.h>$'
+    Priority:        2
+    SortPriority:    3
+  - Regex:           '^<.*\.h>$'
+    Priority:        2
+  - Regex:           '^"_?sd-.*\.h"$'
+    Priority:        4
+  - Regex:           '^"libudev\.h"$'
+    Priority:        4
+  - Regex:           '^"audit_type-to-name.h"$'
+    Priority:        6
+  - Regex:           '.*'
+    Priority:        5
+# Make sure the "main header" is not treated any differently than other headers.
+IncludeIsMainRegex: '^$'
 IndentPPDirectives: AfterHash
 IndentWidth: 8
 IndentWrappedFunctionNames: true