Skip to content
David Lamparter edited this page Jul 24, 2017 · 5 revisions

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:


install clang 4.0

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, it may be advisable to ask for help from someone on the FRR slack.


determine whether to rebase or merge

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

reindent by rebase

  1. switch to your branch
    git checkout mybranch
    
  2. rebase your branch onto the last commit before the reindentation:
    git rebase reindent-master-before
    
  3. (fix any code conflicts this may entail)
  4. use the git-reindent-branch.py script:
    git show master:git-reindent-branch.py > /tmp/git-reindent-branch.py
    python /tmp/git-reindent-branch.py mybranch
    
  5. 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.
  6. 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.


reindent by merge

  1. switch to your branch

    git checkout mybranch
    
  2. merge the last commit before the reindentation into your branch:

    git merge reindent-master-before
    
  3. (fix any code conflicts this may entail)

  4. 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.

  5. reindent your source code:

    python indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`
    
  6. 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.)

  7. Push the branch out.