blob: 4dc9b0771c3c2c745d737ad228423e06d55e84c0 [file] [log] [blame]
Heiko Voigt959b5452015-08-17 17:21:57 -07001#ifndef SUBMODULE_CONFIG_CACHE_H
2#define SUBMODULE_CONFIG_CACHE_H
3
brian m. carlson34caab02018-05-02 00:25:42 +00004#include "cache.h"
Antonio Ospitead136372018-06-26 12:47:05 +02005#include "config.h"
Heiko Voigt959b5452015-08-17 17:21:57 -07006#include "hashmap.h"
Stefan Bellerea2fa5a2016-02-29 18:07:11 -08007#include "submodule.h"
Heiko Voigt959b5452015-08-17 17:21:57 -07008#include "strbuf.h"
9
10/*
11 * Submodule entry containing the information about a certain submodule
12 * in a certain revision.
13 */
14struct submodule {
15 const char *path;
16 const char *name;
17 const char *url;
18 int fetch_recurse;
19 const char *ignore;
Stefan Bellerb5944f32016-07-28 17:44:07 -070020 const char *branch;
Stefan Bellerea2fa5a2016-02-29 18:07:11 -080021 struct submodule_update_strategy update_strategy;
brian m. carlson34caab02018-05-02 00:25:42 +000022 /* the object id of the responsible .gitmodules file */
23 struct object_id gitmodules_oid;
Stefan Beller37f52e92016-05-26 14:59:42 -070024 int recommend_shallow;
Heiko Voigt959b5452015-08-17 17:21:57 -070025};
26
Heiko Voigtc68f8372017-10-16 15:58:27 +020027#define SUBMODULE_INIT { NULL, NULL, NULL, RECURSE_SUBMODULES_NONE, \
brian m. carlson34caab02018-05-02 00:25:42 +000028 NULL, NULL, SUBMODULE_UPDATE_STRATEGY_INIT, { { 0 } }, -1 };
Heiko Voigtc68f8372017-10-16 15:58:27 +020029
Brandon Williamsbf12fcd2017-06-22 11:43:44 -070030struct submodule_cache;
31struct repository;
32
33extern void submodule_cache_free(struct submodule_cache *cache);
34
Brandon Williamsf20e7c12017-08-02 12:49:18 -070035extern int parse_submodule_fetchjobs(const char *var, const char *value);
Stefan Bellerd601fd02017-03-14 14:46:32 -070036extern int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
Stefan Beller886dc152017-06-23 12:13:00 -070037struct option;
38extern int option_fetch_parse_recurse_submodules(const struct option *opt,
39 const char *arg, int unset);
Stefan Bellerd601fd02017-03-14 14:46:32 -070040extern int parse_update_recurse_submodules_arg(const char *opt, const char *arg);
41extern int parse_push_recurse_submodules_arg(const char *opt, const char *arg);
Brandon Williams1b796ac2017-08-03 11:19:57 -070042extern void repo_read_gitmodules(struct repository *repo);
43extern void gitmodules_config_oid(const struct object_id *commit_oid);
Stefan Beller3b8fb392018-03-28 15:35:29 -070044const struct submodule *submodule_from_name(struct repository *r,
45 const struct object_id *commit_or_tree,
46 const char *name);
47const struct submodule *submodule_from_path(struct repository *r,
48 const struct object_id *commit_or_tree,
49 const char *path);
Stefan Bellerf793b892018-03-28 15:35:28 -070050void submodule_free(struct repository *r);
Antonio Ospitebcbc7802018-10-05 15:05:52 +020051int print_config_from_gitmodules(struct repository *repo, const char *key);
Antonio Ospite45f5ef32018-10-05 15:05:53 +020052int config_set_in_gitmodules_file_gently(const char *key, const char *value);
Heiko Voigt959b5452015-08-17 17:21:57 -070053
Jeff King0383bbb2018-04-30 03:25:25 -040054/*
55 * Returns 0 if the name is syntactically acceptable as a submodule "name"
56 * (e.g., that may be found in the subsection of a .gitmodules file) and -1
57 * otherwise.
58 */
59int check_submodule_name(const char *name);
60
Antonio Ospitead136372018-06-26 12:47:05 +020061/*
Antonio Ospite588929d2018-06-26 12:47:08 +020062 * Note: these helper functions exist solely to maintain backward
63 * compatibility with 'fetch' and 'update_clone' storing configuration in
64 * '.gitmodules'.
Antonio Ospitead136372018-06-26 12:47:05 +020065 *
Antonio Ospite588929d2018-06-26 12:47:08 +020066 * New helpers to retrieve arbitrary configuration from the '.gitmodules' file
67 * should NOT be added.
Antonio Ospitead136372018-06-26 12:47:05 +020068 */
Antonio Ospite71a69532018-06-26 12:47:06 +020069extern void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules);
Antonio Ospite05744992018-06-26 12:47:07 +020070extern void update_clone_config_from_gitmodules(int *max_jobs);
Antonio Ospite71a69532018-06-26 12:47:06 +020071
Heiko Voigt959b5452015-08-17 17:21:57 -070072#endif /* SUBMODULE_CONFIG_H */