I'm using multiple C++ github repositories, they all share (as a company standard) the same .clang-format file. We decided to put this file in a separate repository in order to be able to track changes. I'm looking for a way to publish modifications in this file to all relevant repositories. Doing that manually is not and option because I have many repositories.
- I thought to have this repository as a git submodule but in this solution I can't clone the submodule in the root of the repo.
- Thought to clone it into a directory and have a symbolic link to the submodule, but can I have symbolic links in Windows ? the repos are shared between Windows and Linux and Mac
- Have all the repos as a submodules of the clang-format repository and have a script which update all the submodules and create a pull-request automatically.
- Same as 3 but without the submodules, clone each repo and copy the new file Do you have any other better option ?
While submodule remains the best option (especially with an associated branch, which makes updating its content as easy as
git submodule update --remote
), you would still need a preprocessing step before building.I usually version a
build.bat
script (like this one for instance) in charge of setting up the environment and building the project.That script can also check if the
.clang-format
is present at the root folder and, if not, copy it from the submodule.Since every user of that repository will have to call
build.bat
to... build the project, they won't even have to be aware of that preprocessing step.The OP sagi adds in the comments:
That is where a content filter driver declared in a
.gitattributes
file can help.You still need to each user to type a command first:
And you need to verion a dummy file
.clang-format.tpl
to associate that particular file with thesmudge
script.But the idea that the smudge script will be called on
git clone
orgit checkout
/git switch
automatically, and can set up any missing file for you.That way, the format file is ready as soon as you are launching your IDE.