How can I reduce the amount of memory for multiple submodules of the same source?
I have a large project that contains several Git submodules. The main project uses a collection of different libraries, and some libraries use the libraries themselves. All libraries can be used in standonlone mode, so they all need a submodule that contains the test framework (VUnit and UVVM).
The Git submodule tree looks like this:
ProjectA
o- libA
o- UVVM
o- VUnit
o- libB
o- UVVM
o- VUnit
o- libC
o- libA
o- UVVM
o- VUnit
o- UVVM
o- VUnit
o- libD
o- UVVM
o- VUnit
o- UVVM
o- VUnit
I have knowledge of internal database and Git link structure. Therefore, BLOB submodules are stored in the .git
main repository directory under a directory named modules
. They usually have the same symbolic name as the submodule directory name.
The submodule points to the main directory of its database with a file .git
containing the relative path. In turn, the submodule database configuration file points to the submodule working tree.
So, it's possible that all UVVM submodules point to the same database, but how is it possible that a database points to multiple worker trees?
I found a Git extension to work with multiple worker dirs, but also does it work with submodules like in my case?
I am also open to other suggestions.
Edit 1:
This is the generated internal directory structure .git
. It builds over the complete object store for each submodule for UVVM and VUnit over and over again.
.git/ modules/ libA/ modules/ UVVM/ VUnit/ libB/ modules/ UVVM/ VUnit/ libC/ modules/ libA/ modules/ UVVM/ VUnit/ UVVM/ VUnit/ libD/ modules/ UVVM/ VUnit/ UVVM/ VUnit/
The server memory is very low because all submodules point to the same repository. But the client side memory is very high.
source to share
If we take .git/modules/libA/modules/UVVM
as the only source repository:
- Remove ProjectA / lib B / UVVM (working tree)
- Remove ProjectA / .git / modules / lib B / modules / UVVM (source repository)
- cd ProjectA / lib A / UVVM
- Create a LibB branch in ProjectA / lib A / UVVM submodule (repositories)
- for ProjectA / lib B / UVVM.
- run
git worktree add ../../libB/UVVM LibB
Now working tree LibA/UVVM
and LibB/UVVM
share the same source repository .git/modules/libA/modules/UVVM
.
Repeat the same with the others UVVM
, and the same thing with VUnit
.
source to share