-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Reindenting
FRR's master branch has been reindented to Linux kernel CodingStyle on Monday, July 17th, 2017. To adapt your local in-development branches, follow these instructions:
You need clang 4.0
to automatically reindent your source code. You can hopefully find it in your distribution's packages. If it's not easily possible to install clang 4.0
, you can download a prebuilt binary package for most distributions here.
A branch can be adjusted for the whitespace changes either by merging or rebasing the reindentation. You need to pick one of the 2 approaches.
You should merge, if:
- the branch already contains other merges
- the branch shares history with other branches
- the branch's commit IDs are otherwise important
You should rebase, if:
- the branch is small to medium in size
- the branch forks off master without any further merges
- the branch contains development history that you want to flatten/squash anyway
- switch to your branch
git checkout mybranch
- rebase your branch onto the last commit before the reindentation:
git rebase reindent-master-before
- (fix any code conflicts this may entail)
- use the
git-reindent-branch.py
script:git show master:git-reindent-branch.py > git-reindent-branch.py python git-reindent-branch.py mybranch
- if the script successfully completes, you now have a branch named
reindented-branch
in your working directory. This branch should contains all of your commits, identical for all purposes except that all of the code should be properly indented. Please check that its history and diff looks correct. - Make a backup of your previous branch, then replace your branch with
reindented-branch
and delete the latter:NOTE:git branch backup/mybranch HEAD git reset --hard reindented-branch git branch -D reindented-branch
git reset
will overwrite your current HEAD with the reindented output here. Don't switch to another branch in the middle. - Rebase your branch again to bring it up to date with master:
git rebase master
- (fix any code conflicts this may entail)
- Force-Push your branch to any repositories that have a copy of it:
git push -f somerepo mybranch
-
switch to your branch
git checkout mybranch
-
merge the last commit before the reindentation into your branch:
git merge reindent-master-before
-
(fix any code conflicts this may entail)
-
perform a no-op merge of the reindentation:
git merge --strategy=ours reindent-master-after
This does not actually do any change to your source code; it creates an "empty" merge commit that doesn't actually merge anything.
NOTE: do NOT replace reindent-master-after with master. It is essential to merge exactly this tag/commit.
-
reindent your source code:
python indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
-
add the reindentation changes and amend them into the merge:
git add -u git commit --amend
(This really should be amended and not left as a separate commit because the latter would interfere with the next merge of/into master.)
-
merge current master to bring the branch up to date:
git merge master
-
(fix any code conflicts this may entail)
-
Push the branch out.