2015-08-18 02:21:57 +02:00
|
|
|
submodule config cache API
|
|
|
|
==========================
|
|
|
|
|
|
|
|
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 .gitmodule files. Lookups can be done by
|
|
|
|
submodule path or name.
|
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
2015-08-18 02:21:59 +02:00
|
|
|
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.
|
|
|
|
|
2015-08-18 02:21:57 +02:00
|
|
|
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
|
2015-08-18 02:21:59 +02:00
|
|
|
initializes and allocates the needed infrastructure on-demand. If the
|
|
|
|
caller does only want to lookup values from revisions the initialization
|
|
|
|
can be skipped.
|
2015-08-18 02:21:57 +02:00
|
|
|
|
|
|
|
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().
|
|
|
|
|
|
|
|
Data Structures
|
|
|
|
---------------
|
|
|
|
|
|
|
|
`struct submodule`::
|
|
|
|
|
|
|
|
This structure is used to return the information about one
|
|
|
|
submodule for a certain revision. It is returned by the lookup
|
|
|
|
functions.
|
|
|
|
|
|
|
|
Functions
|
|
|
|
---------
|
|
|
|
|
|
|
|
`void submodule_free()`::
|
|
|
|
|
|
|
|
Use these to free the internally cached values.
|
|
|
|
|
2015-08-18 02:21:59 +02:00
|
|
|
`int parse_submodule_config_option(const char *var, const char *value)`::
|
|
|
|
|
|
|
|
Can be passed to the config parsing infrastructure to parse
|
|
|
|
local (worktree) submodule configurations.
|
|
|
|
|
2016-11-22 21:14:37 +01:00
|
|
|
`const struct submodule *submodule_from_path(const unsigned char *treeish_name, const char *path)`::
|
2015-08-18 02:21:57 +02:00
|
|
|
|
2016-11-22 21:14:37 +01:00
|
|
|
Given a tree-ish in the superproject and a path, return the
|
|
|
|
submodule that is bound at the path in the named tree.
|
2015-08-18 02:21:57 +02:00
|
|
|
|
2016-11-22 21:14:37 +01:00
|
|
|
`const struct submodule *submodule_from_name(const unsigned char *treeish_name, const char *name)`::
|
2015-08-18 02:21:57 +02:00
|
|
|
|
|
|
|
The same as above but lookup by name.
|
|
|
|
|
2016-11-22 21:14:38 +01:00
|
|
|
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
|
2015-08-18 02:21:59 +02:00
|
|
|
configuration and the .gitmodules file in the worktree).
|
|
|
|
|
2015-08-18 02:21:57 +02:00
|
|
|
For an example usage see test-submodule-config.c.
|