Skip to content

beautify code with clang-format#662

Merged
stevengj merged 1 commit intomasterfrom
run-clang-format
Jan 11, 2019
Merged

beautify code with clang-format#662
stevengj merged 1 commit intomasterfrom
run-clang-format

Conversation

@stevengj
Copy link
Collaborator

@stevengj stevengj commented Jan 10, 2019

Following up on #657, this PR makes no changes except to run clang-format -i on all of the C++ code, giving it a uniform formatting. (Previously, the code was a mishmash of styles due to different programmers and editor settings over the years, along with mangled indentation from tab/spaces conversions.)

Once this is merge, existing PR's and other branches will have zillions of conflicts, but if you follow a very careful procedure then this can be dealt with automatically:

  1. First rebase onto the previous commit to this one (0545e3f) and fix any conflicts.

  2. Then run clang-format -i on your code and commit it.

  3. Then rebase onto this commit (b99fe3f), ignoring conflicts with git rebase -Xtheirs

Summary:

Instructions for rebasing other branches after this PR:

Replace MYBRANCH below with the name of your branch:

# update repo
git checkout master && git pull origin master # update master
rm -f python/*-python.cpp python/.deps/*-python.Plo # rm old swig files

# switch to your branch
git checkout MYBRANCH

# rebase onto PREVIOUS commit
git rebase 0545e3f1b82739c28c3bb3a9b383497520efe028

# reformat and rebase to THIS PR's commit
find . -name '*.*pp' | xargs clang-format -i
git commit -a -m "reformat"
git rebase -Xtheirs b99fe3fe5a709e5a9328cac04a29444e044fe21e

# finish rebase
git rebase master

@stevengj
Copy link
Collaborator Author

I tried the above procedure on #635 and it seems to have gone smoothly.

@zerothi
Copy link
Contributor

zerothi commented Aug 29, 2024

Just a suggestion, when doing stuff like this, it might be useful to add the commit that only introduces formatting changes to a .git-blame-ignore-revs. In this way one can more easily backtrack stuff in terms of changes.

Some more context here: https://gist.github.com/kateinoigakukun/b0bc920e587851bfffa98b9e279175f2

(same goes for mpb if that PR goes in).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants