[gdal-dev] Code reformatting applied

Even Rouault even.rouault at spatialys.com
Sat Dec 17 13:20:12 PST 2022


Hi,

The code reformatting has now landed into master and release/3.6 
branches per pull requests https://github.com/OSGeo/gdal/pull/6937 and 
https://github.com/OSGeo/gdal/pull/6939. I've applied it now since the 
number of opened pull requests is low. I've split the reformatting in 
one commit per modified directory, to avoid potential issues with UI 
like github that could have performance issues with a single huge commit.

For developers, when you'll have resynchronized your local copy with 
master, do the following from the top of your clone so that commits with 
code reformatting are ignored when using "git blame"

git config blame.ignoreRevsFile .git-blame-ignore-revs

This is documented in 
https://gdal.org/development/dev_practices.html#blame-ignore-file

If you have ongoing work in local branches not sent as PR, and that you 
intend to submit as a single-commit (or squashed as a single-commit on 
merging), do *not* merge master into it, otherwise you'll get conflicts. 
But you can apply the following workflow to reformat your modified files 
to comply with the formatting rules:

git fetch upstream master # assuming 'upstream' points to OSGeo/gdal
git checkout -b reformatted_branch  # to not mess up with your original work
git cherry-pick 5d80bc1 2796f2a b9c28a1 3103e5e 48c9ea8cb4  # to fetch 
modified pre-commit hook and .clang-format
pip install pre-commit # if not already done
pre-commit install # if not already done
pre-commit run --files foo/bar.cpp bar/baz.h  # put here the list of 
your modified files to reformat

Copy all your modified files as .cpp.new / .h.new ones for example

Create a new branch from latest master and copy the .cpp.new / .h.new 
files on top of the .cpp / .h ones (or use a merge tool if there have 
been conflicting changes in between to only merge your changes)

If you want your work to be merged as multiple commits, then I'm afraid 
you'll have to endure some pain to create copies of modified files by 
each commit in their before and after state, reformat those different 
versions, generate patches with the diff between the reformated 
before/after versions, and use those diffs with git apply to recreate 
commits in a new branch on top of latest master

Even

-- 
http://www.spatialys.com
My software is free, but my time generally not.



More information about the gdal-dev mailing list