-
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. Check that its history and diff looks correct, and/or rename your current branch and leave it as backup. - Replace your branch with
reindented-branch
, force-push it to any repositories neccessary.
The output branch will be based on the reindent-master-after
tag, not the most recent master. You may want to rebase it to master with normal git rebase
.
-
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
NOTE: this does not actually do any change to your source code.
-
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.)
-
Push the branch out.