[GRASS-dev] C code indented

Dear all,

Most of the C and C++ code was indented using our ./utils/grass_indent_ALL.sh script at the FOSS4G 2022 sprint. This will help to indent code for PRs and with the transition to clang-format.

Directories with files which indent reports issues for were not updated, because more changes are needed in the code.

This may create conflicts in some existing PR which modify C code. If you have a conflict related to this (old PR may have other conflicts too), you can follow this procedure:

Indent your code:

./utils/grass_indent.sh db/drivers/mysql/create_table.c

Commit the change:

git commit -m “Indent PR code” db/drivers/mysql/create_table.c

Update upstream/main branch:

git fetch upstream

Merge into your branch upstream/main:

git merge --strategy=recursive --strategy-option=ours upstream/main

Let me know if you have any questions,
Vaclav

I have resolved all indentation-related conflicts in the open PRs. The procedure worked well on all PRs except one which had changes in directories which were not indented yet.

The remaining issues are:

There are directories where indent reports an error, esp. due to ambiguities in the current code formatting. These are not indented yet. These would be best resolved by separate PRs, possibly separating the ambiguity fixes from the overall formatting changes (esp. given that we want to ignore purely formatting changes in git blame).

Formatting needs to be enforced in the CI. This can be done with something like re-indent followed by git diff.

Best,

Vaclav

On Sat, 27 Aug 2022 at 14:06, Vaclav Petras <wenzeslaus@gmail.com> wrote:

Dear all,

Most of the C and C++ code was indented using our ./utils/grass_indent_ALL.sh script at the FOSS4G 2022 sprint. This will help to indent code for PRs and with the transition to clang-format.

Directories with files which indent reports issues for were not updated, because more changes are needed in the code.

This may create conflicts in some existing PR which modify C code. If you have a conflict related to this (old PR may have other conflicts too), you can follow this procedure:

Indent your code:

./utils/grass_indent.sh db/drivers/mysql/create_table.c

Commit the change:

git commit -m “Indent PR code” db/drivers/mysql/create_table.c

Update upstream/main branch:

git fetch upstream

Merge into your branch upstream/main:

git merge --strategy=recursive --strategy-option=ours upstream/main

Let me know if you have any questions,
Vaclav

On Tue, 13 Sept 2022 at 09:33, Vaclav Petras <wenzeslaus@gmail.com> wrote:

Formatting needs to be enforced in the CI. This can be done with something like re-indent followed by git diff.

Maybe something like this could be used? https://github.com/marketplace/actions/clang-format-check Note that it doesn’t actually format the code, but would complain like the current black formatter for python :thinking:

or perhaps https://github.com/material-foundation/clang-format-ci seems to do the same, and leaves inline comments

–Wolf

Best,

Vaclav

On Sat, 27 Aug 2022 at 14:06, Vaclav Petras <wenzeslaus@gmail.com> wrote:

Dear all,

Most of the C and C++ code was indented using our ./utils/grass_indent_ALL.sh script at the FOSS4G 2022 sprint. This will help to indent code for PRs and with the transition to clang-format.

Directories with files which indent reports issues for were not updated, because more changes are needed in the code.

This may create conflicts in some existing PR which modify C code. If you have a conflict related to this (old PR may have other conflicts too), you can follow this procedure:

Indent your code:

./utils/grass_indent.sh db/drivers/mysql/create_table.c

Commit the change:

git commit -m “Indent PR code” db/drivers/mysql/create_table.c

Update upstream/main branch:

git fetch upstream

Merge into your branch upstream/main:

git merge --strategy=recursive --strategy-option=ours upstream/main

Let me know if you have any questions,
Vaclav


grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

On Sat, 17 Sept 2022 at 04:57, Wolf Bergenheim <wolf+grass@bergenheim.net> wrote:

On Tue, 13 Sept 2022 at 09:33, Vaclav Petras <wenzeslaus@gmail.com> wrote:

Formatting needs to be enforced in the CI. This can be done with something like re-indent followed by git diff.

Maybe something like this could be used? https://github.com/marketplace/actions/clang-format-check Note that it doesn’t actually format the code, but would complain like the current black formatter for python :thinking:

or perhaps https://github.com/material-foundation/clang-format-ci seems to do the same, and leaves inline comments

Yes, please. We need to transition to clang-format and one of these clang-format wrappers for CI will be needed. You can open an experimental PR if you want. See also #2272.

https://github.com/OSGeo/grass/pull/2272