When you wish to introduce a code format to your repo, one of the daunting artifact is garbaging each commits from now on, with formatting changes.
This trushes the git blame
tool, since the "last changes" are probably the formatting, and not the original logical commit.
This repo is here for the rescue :-)
It re-format your repo from the begining of time, to the latest commit.
The script here will re-format every commit ever done on the repo, so branches are covered :-)
It is a dangarues process, so do it on a copy of your git repo.
This repo is really just a minimal re-packaging of this great great git-filter-repo tool.
- Have the
clang-format
tool installed. the npm way looks nice:npm install --location=global clang-format
. - Clone this repo to a folder somwhere, say,
/tmp/formatter
- Edit the
.clang-format
to suite your needs. here is a visualised online way to do that. - Goto your repo, and run
/tmp/formatter/re-format.sh
- Validate your repo integrity - build, unit-test, etc.
- Make sure every commit from now on is formated.
The tools for this are:git clang-format
, pre-commit hook, and/or CI bot/action. (good blog post)