Clone
3
clang format
ailin-nemui edited this page 2021-01-12 12:17:02 +01:00

New code should be formatted according to .clang-format file before committing it in a pull request. ( https://clang.llvm.org/docs/ClangFormat.html )

It can be installed with apt install clang-format or zypper in clang-tools

Only the modified code should be reformatted using clang-format, otherwise the code diff files get impossible to review. Use git-clang-format to do this (see below).

Checking XS files

To also correct the formatting of XS files, configure clang-format to use the clang-format-xs wrapper like so

git config clangformat.extensions c,h,xs
git config clangformat.binary $PWD/utils/clang-format-xs/clang-format-xs

Manual check after git add

Use:

git clang-format

Auto-check format on commit

To ensure the clang-format formatting before committing, I found this tool:

https://github.com/ailin-nemui/clang-format-hooks

To use it, first clone the repo ( git clone https://github.com/ailin-nemui/clang-format-hooks.git )

Then, run the installer script inside your Irssi clone:

cd /path/to/src/irssi
../clang-format-hooks/git-pre-commit-format install

The next time you try to commit, the formatting will be checked!

Emacs integration

See Emacs