Setup and Config
Getting and Creating Projects
Basic Snapshotting
Branching and Merging
Sharing and Updating Projects
Inspection and Comparison
Patching
Debugging
External Systems
Server Admin
Guides
- gitattributes
- Command-line interface conventions
- Everyday Git
- Frequently Asked Questions (FAQ)
- Glossary
- Hooks
- gitignore
- gitmodules
- Revisions
- Submodules
- Tutorial
- Workflows
- All guides...
Administration
Plumbing Commands
- 2.18.1 → 2.24.4 no changes
-
2.18.0
2018-06-21
- 2.17.0 → 2.17.6 no changes
-
2.16.6
2019-12-06
- 2.13.7 → 2.15.4 no changes
-
2.12.5
2017-09-22
- 2.7.6 → 2.11.4 no changes
-
2.6.7
2017-05-05
The submodule config cache API allows to read submodule configurations/information from specified revisions. Internally information is lazily read into a cache that is used to avoid unnecessary parsing of the same .gitmodules files. Lookups can be done by submodule path or name.
Usage
To initialize the cache with configurations from the worktree the caller
typically first calls gitmodules_config() to read values from the
worktree .gitmodules and then to overlay the local git config values
parse_submodule_config_option() from the config parsing
infrastructure.
The caller can look up information about submodules by using the
submodule_from_path() or submodule_from_name() functions. They return
a struct submodule which contains the values. The API automatically
initializes and allocates the needed infrastructure on-demand. If the
caller does only want to lookup values from revisions the initialization
can be skipped.
If the internal cache might grow too big or when the caller is done with the API, all internally cached values can be freed with submodule_free().
Functions
voidsubmodule_free(structrepository*r)-
Use these to free the internally cached values.
intparse_submodule_config_option(constchar*var,constchar*value)-
Can be passed to the config parsing infrastructure to parse local (worktree) submodule configurations.
conststructsubmodule*submodule_from_path(constunsignedchar*treeish_name,constchar*path)-
Given a tree-ish in the superproject and a path, return the submodule that is bound at the path in the named tree.
conststructsubmodule*submodule_from_name(constunsignedchar*treeish_name,constchar*name)-
The same as above but lookup by name.
Whenever a submodule configuration is parsed in parse_submodule_config_option
via e.g. gitmodules_config(), it will overwrite the null_sha1 entry.
So in the normal case, when HEAD:.gitmodules is parsed first and then overlayed
with the repository configuration, the null_sha1 entry contains the local
configuration of a submodule (e.g. consolidated values from local git
configuration and the .gitmodules file in the worktree).
For an example usage see test-submodule-config.c.