submodule: implement a config API for lookup of .gitmodules values
[git] / Documentation / technical / api-submodule-config.txt
1 submodule config cache API
2 ==========================
3
4 The submodule config cache API allows to read submodule
5 configurations/information from specified revisions. Internally
6 information is lazily read into a cache that is used to avoid
7 unnecessary parsing of the same .gitmodule files. Lookups can be done by
8 submodule path or name.
9
10 Usage
11 -----
12
13 The caller can look up information about submodules by using the
14 `submodule_from_path()` or `submodule_from_name()` functions. They return
15 a `struct submodule` which contains the values. The API automatically
16 initializes and allocates the needed infrastructure on-demand.
17
18 If the internal cache might grow too big or when the caller is done with
19 the API, all internally cached values can be freed with submodule_free().
20
21 Data Structures
22 ---------------
23
24 `struct submodule`::
25
26         This structure is used to return the information about one
27         submodule for a certain revision. It is returned by the lookup
28         functions.
29
30 Functions
31 ---------
32
33 `void submodule_free()`::
34
35         Use these to free the internally cached values.
36
37 `const struct submodule *submodule_from_path(const unsigned char *commit_sha1, const char *path)`::
38
39         Lookup values for one submodule by its commit_sha1 and path.
40
41 `const struct submodule *submodule_from_name(const unsigned char *commit_sha1, const char *name)`::
42
43         The same as above but lookup by name.
44
45 For an example usage see test-submodule-config.c.