How to fix conflicts due to the clang-format reformatting of the Nektar++ codebase
MR !1359 modifies the way source code is formatted. In practice, it modifies allm the Nektar++ source code files to apply the new standard code layout.
If your Merge Request is based on changes made before commit **<merge commit>**, theses changes will conflict with the reformatting on the `master` branch. To fix these conflicts, you can follow the procedure below. If your changes are based on commit **<merge commit>** or child commit, you can ignore this issue.
First things first, you'll need `clang-format` version 11.
- Ubuntu/Debian
```
sudo apt update && sudo apt install clang-format-11
```
- Fedora/OpenSUSE
```
dnf install clang-format-11
```
- MacPorts
```
port install llvm-11 # use `clang-format-11`
```
- Homebrew
```
brew install clang-format@11
```
Now, conflicts due to formatting can be fixed with:
1. Make sure you are not currently running any merge operation
```
git merge --abort
```
2. Fetch the latest changes on the upstream `master` branch
```
git fetch origin master
```
3. If you have local changes (staged or unstaged), commit them or stash them. `git status` should print something close to
```
nothing added to commit [but untracked files present (use "git add" to track)]
```
4. Merge the last commit before the reformatting branch was merged in the `master` branch. If you haven't updated your local branch in a while, it is likely that you will have to fix conflicts.
```
git merge fedf53148fd4f0f5387b40f34fd8de6401446bde
```
5. Apply `clang-format-11` to files modified since branching off from `master`
```
git diff $(git merge-base origin/master HEAD) --name-only -- "*.cpp" "*.h" ".hpp" ".hxx" | xargs clang-format-11 -i
```
where `origin` refers to the `git@gitlab.nektar.info:nektar/nektar.git` remote. You may have named it in a different way, .e.g `upstream`.
**Important**: Use clang-format **version 11**. On some platforms the name of the executable may differ; for example MacPorts installations should use the command `clang-format-mp-11`.
6. Stage and commit the changes
```
git commit -am "[formatting] Apply clang-format-11"
```
7. Merge the reformat commit into your branch, marking your version as the correct one in case of conflicting changes
```
git merge 6a3e03cf6 -s recursive -Xours
```
You branch is now up to date with the state of the `master` branch right after the reformatting was introduced. If your branch is still conflicting with the `master` branch, it is because your local changes conflict with changes made on the `master` branch _after_ the reformatting was introduced. In other words these are normal conflicts, unrelated to the reformatting of the code base.
issue