diff --git a/.clang-format b/.clang-format index a3ef233a243d..bc97efc80c61 100644 --- a/.clang-format +++ b/.clang-format @@ -4,3 +4,5 @@ UseTab: Always BreakBeforeBraces: Linux AllowShortIfStatementsOnASingleLine: false IndentCaseLabels: false +SortIncludes: CaseSensitive +IncludeBlocks: Preserve diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f8cf87d5d369..99793dfc71d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,6 +18,18 @@ repos: - id: shellcheck args: [ -fgcc ] +- repo: https://github.com/pre-commit/mirrors-clang-format + rev: v19.1.4 + hooks: + - id: clang-format + description: Runs formatting checks on the c code and and throws errors if suggestions + are detected, without modifying the code. Style is defined in `.clang-format`. When + encountering formatting-related errors, run `clang-format -i ` to make + (destructively) the suggestions and evalute the resulting diff for more context. + args: [ --dry-run, -Werror ] + entry: clang-format + types: [ c ] + - repo: local hooks: # Reimplementation of `make check-amount-access` for pygrep.