Skip to content

ehsan/clang-format-reformat-branch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clang-format-reformat-branch

This script is designed to help Mozilla developers who use git with rebasing their local changes after the tree-wide conversion planned to the Google C++ Coding Style.

This is based on the MongoDB clang_format.py script[1] explained in [2]. Many thanks to the MongoDB project for providing the original script.

Instructions

After the tree-wide conversion planned to happen on Nov 30 2018 [3], you can follow the following steps in order to rebase your local changes on top of the reformatted tree.

  • Clone this repository somewhere on your local disk.

  • Run this command inside your clone directory:

  • pip install -r requirements.txt

  • Use git remote update to pull in the reformat commit into your local git repository (but don't try to merge with it or rebase on top of it just yet, you only want to make sure the git commit exists in the git database)

  • Find out the commit SHA1s for the rewrite commit. For example if the remote branch that you pulled from in the previous step is called "m-c", you can run this command to find the commit:

  • git log --grep=1511181 m-c # grep for the bug number in the commit message

  • Let's assume this commit is abcdef12.

  • Rebase your local branch on top of the parent of that commit (abcdef12~) and ensure any possible conflicts have been resolved.

  • Run the following command in the root of your mozilla-central checkout:

  • /path/to/clang-format-reformat-branch/clang_format.py reformat-branch abcdef12 abcdef12~ m-c

  • m-c here is the remote branch that is tracking mozilla-central, which is usually where the reformat commit has come from. If you use this popular github repo [4], then this is probably called "central" in your setup.

This command first makes a few checks in the environment to ensure that everything is right and if not shows prompts about what went wrong and after that starts the rebase process. As the rebase is happening, it uses ./mach clang-format under the hood to reformat each one of the files in your patches which have been modified and then rebases the patch on top of the reformat commit.

If you start running this command on git branch called "foo", this command will save its result on a new git branch called "foo-reformatted" and will check it out when it's finished. It will not modify the original "foo" branch in any way, so it is not destructive. If you're happy with the results, you may run the following commands to make the results permanent:

  • git checkout foo
  • git reset --hard foo-reformatted # make sure the local directory is unmodified!!!

References

About

A script for Mozilla developers to rebase their local changes after the tree-wise reformat to the Google C++ Style

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages