From 0561f953c493140b848c1279581ad15919f42685 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 25 Feb 2021 10:53:22 +0100 Subject: [PATCH] docs: document code formatting in HACKING.md --- HACKING.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/HACKING.md b/HACKING.md index dbd2327d..b8aed612 100644 --- a/HACKING.md +++ b/HACKING.md @@ -9,6 +9,31 @@ Currently dracut lives on github.com and kernel.org. Pull requests should be filed preferably on github nowadays. +### Code Format + +It is recommended, that you install a plugin for your editor, which reads in `.editorconfig`. +Additionally `emacs` and `vim` config files are provided for convenience. + +To reformat C files use `indent`: +```console +$ indent -i8 -nut -br -linux -l120 +``` + +For convenience there is also a Makefile `indent` target `make indent`. + +To reformat shell files use `shfmt`: + +```console +$ shfmt_version=3.0.1 +$ wget "https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_linux_amd64" -O shfmt +$ chmod u+x shfmt +$ ./shfmt -w -s . +``` + +Some IDEs already have support for shfmt. + +For convenience the `make indent` Makefile target also calls shfmt, if it is in `$PATH`. + ### Commit Messages Commit messages should answer these questions: