Commit 60cae20
committed
style: Introduce clang-format configurations for automated enforcement
This commit introduces a formatting pipeline to enforce consistent
coding standards across the rsync codebase using clang-format.
The root `_clang-format` file is configured to enforce the Linux Kernel
(K&R) coding style, specifically adapted for rsync's historical baseline
and to account for developer habits:
- 8-character hardware tabs for all indentation
- 80-column line length limit
- K&R brace placement (same line for control statements, new line
for function definitions)
- Function names and return types sharing the same line
Additionally, local `_clang-format` overrides have been added to the
`popt/` and `zlib/` vendored library directories. These files inherit
the root Linux structural rules but override the indentation to 4 spaces
to respect their specific upstream formatting requirements.
Usage:
To automatically apply the formatting rules and modify the files in-place,
run the following command from the root directory:
find . -name "*.c" -o -name "*.h" | xargs clang-format -i
To automatically apply the formatting rules and modify a single file
in-place, run the following command from the root directory:
clang-format -i <path/to/file>
To validate code compliance without modifying the files (for use
in pre-commit hooks or CI pipelines), run the dry-run command:
find . -name "*.c" -o -name "*.h" | xargs clang-format --dry-run --Werror
To validate code compliance for a single file, without modification, run
the dry-run command:
clang-format --dry-run --Werror <path/to/file>
This commit is designed to work in conjunction with .editorconfig files
but can be used standalone.
Additionally, a proposed STYLEGUIDE.md file is included in the root
directory for publishing where appropriate.
Signed-off by: Wayne Michael Thornton <wmthornton-dev@outlook.com>1 parent 5cf7c50 commit 60cae20
4 files changed
Lines changed: 1335 additions & 0 deletions
0 commit comments