Reputation: 522
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.
Upvotes: 3
Views: 1000
Reputation: 1328322
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:
but build phase might be a little late because I want the formatting to happen in the IDE while coding.
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:
git config --global filter.clang.smudge 'script_install_clang'
And you need to verion a dummy file .clang-format.tpl
to associate that particular file with the smudge
script.
But the idea that the smudge script will be called on git clone
or git 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.
Upvotes: 1