2009-10-19 12:38:32 +00:00
|
|
|
#ifndef SUBMODULE_H
|
|
|
|
#define SUBMODULE_H
|
|
|
|
|
2010-06-25 14:56:47 +00:00
|
|
|
struct diff_options;
|
2012-09-01 15:27:06 +00:00
|
|
|
struct argv_array;
|
2017-03-31 01:40:00 +00:00
|
|
|
struct oid_array;
|
2017-04-05 17:47:19 +00:00
|
|
|
struct remote;
|
2010-06-25 14:56:47 +00:00
|
|
|
|
2011-03-06 22:10:46 +00:00
|
|
|
enum {
|
2016-12-19 18:25:32 +00:00
|
|
|
RECURSE_SUBMODULES_ONLY = -5,
|
2015-11-17 11:05:56 +00:00
|
|
|
RECURSE_SUBMODULES_CHECK = -4,
|
2015-08-18 00:22:00 +00:00
|
|
|
RECURSE_SUBMODULES_ERROR = -3,
|
2015-08-18 00:21:57 +00:00
|
|
|
RECURSE_SUBMODULES_NONE = -2,
|
2011-03-06 22:10:46 +00:00
|
|
|
RECURSE_SUBMODULES_ON_DEMAND = -1,
|
|
|
|
RECURSE_SUBMODULES_OFF = 0,
|
|
|
|
RECURSE_SUBMODULES_DEFAULT = 1,
|
|
|
|
RECURSE_SUBMODULES_ON = 2
|
|
|
|
};
|
|
|
|
|
2016-03-01 02:07:11 +00:00
|
|
|
enum submodule_update_type {
|
|
|
|
SM_UPDATE_UNSPECIFIED = 0,
|
|
|
|
SM_UPDATE_CHECKOUT,
|
|
|
|
SM_UPDATE_REBASE,
|
|
|
|
SM_UPDATE_MERGE,
|
|
|
|
SM_UPDATE_NONE,
|
|
|
|
SM_UPDATE_COMMAND
|
|
|
|
};
|
|
|
|
|
|
|
|
struct submodule_update_strategy {
|
|
|
|
enum submodule_update_type type;
|
|
|
|
const char *command;
|
|
|
|
};
|
2016-03-01 02:07:13 +00:00
|
|
|
#define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED, NULL}
|
2016-03-01 02:07:11 +00:00
|
|
|
|
2016-12-20 23:20:09 +00:00
|
|
|
extern int is_staging_gitmodules_ok(void);
|
|
|
|
extern int update_path_in_gitmodules(const char *oldpath, const char *newpath);
|
|
|
|
extern int remove_path_from_gitmodules(const char *path);
|
|
|
|
extern void stage_updated_gitmodules(void);
|
|
|
|
extern void set_diffopt_flags_from_submodule_config(struct diff_options *,
|
2010-08-05 22:39:25 +00:00
|
|
|
const char *path);
|
2016-12-20 23:20:09 +00:00
|
|
|
extern int submodule_config(const char *var, const char *value, void *cb);
|
2017-06-01 00:30:47 +00:00
|
|
|
extern int git_default_submodule_config(const char *var, const char *value, void *cb);
|
2017-05-26 19:10:12 +00:00
|
|
|
|
|
|
|
struct option;
|
|
|
|
int option_parse_recurse_submodules_worktree_updater(const struct option *opt,
|
|
|
|
const char *arg, int unset);
|
|
|
|
void load_submodule_cache(void);
|
2016-12-20 23:20:09 +00:00
|
|
|
extern void gitmodules_config(void);
|
2016-12-16 19:03:18 +00:00
|
|
|
extern void gitmodules_config_sha1(const unsigned char *commit_sha1);
|
2016-12-16 19:03:17 +00:00
|
|
|
extern int is_submodule_initialized(const char *path);
|
2017-03-14 21:46:31 +00:00
|
|
|
/*
|
|
|
|
* Determine if a submodule has been populated at a given 'path' by checking if
|
|
|
|
* the <path>/.git resolves to a valid git repository.
|
|
|
|
* If return_error_code is NULL, die on error.
|
|
|
|
* Otherwise the return error code is the same as of resolve_gitdir_gently.
|
|
|
|
*/
|
|
|
|
extern int is_submodule_populated_gently(const char *path, int *return_error_code);
|
2017-05-09 19:17:59 +00:00
|
|
|
extern void die_in_unpopulated_submodule(const struct index_state *istate,
|
|
|
|
const char *prefix);
|
2017-05-11 22:04:24 +00:00
|
|
|
extern void die_path_inside_submodule(const struct index_state *istate,
|
|
|
|
const struct pathspec *ps);
|
2016-12-20 23:20:09 +00:00
|
|
|
extern int parse_submodule_update_strategy(const char *value,
|
2016-03-01 02:07:11 +00:00
|
|
|
struct submodule_update_strategy *dst);
|
2016-12-20 23:20:09 +00:00
|
|
|
extern const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);
|
|
|
|
extern void handle_ignore_submodules_arg(struct diff_options *, const char *);
|
|
|
|
extern void show_submodule_summary(FILE *f, const char *path,
|
2013-04-05 16:12:08 +00:00
|
|
|
const char *line_prefix,
|
2016-08-31 23:27:23 +00:00
|
|
|
struct object_id *one, struct object_id *two,
|
2012-11-13 15:42:47 +00:00
|
|
|
unsigned dirty_submodule, const char *meta,
|
2009-10-19 12:38:32 +00:00
|
|
|
const char *del, const char *add, const char *reset);
|
2016-12-20 23:20:09 +00:00
|
|
|
extern void show_submodule_inline_diff(FILE *f, const char *path,
|
2016-08-31 23:27:25 +00:00
|
|
|
const char *line_prefix,
|
|
|
|
struct object_id *one, struct object_id *two,
|
|
|
|
unsigned dirty_submodule, const char *meta,
|
|
|
|
const char *del, const char *add, const char *reset,
|
|
|
|
const struct diff_options *opt);
|
2016-12-20 23:20:09 +00:00
|
|
|
extern void set_config_fetch_recurse_submodules(int value);
|
2017-03-14 21:46:34 +00:00
|
|
|
/* Check if we want to update any submodule.*/
|
|
|
|
extern int should_update_submodules(void);
|
|
|
|
/*
|
|
|
|
* Returns the submodule struct if the given ce entry is a submodule
|
|
|
|
* and it should be updated. Returns NULL otherwise.
|
|
|
|
*/
|
|
|
|
extern const struct submodule *submodule_from_ce(const struct cache_entry *ce);
|
2017-03-26 16:01:35 +00:00
|
|
|
extern void check_for_new_submodule_commits(struct object_id *oid);
|
2016-12-20 23:20:09 +00:00
|
|
|
extern int fetch_populated_submodules(const struct argv_array *options,
|
2011-03-06 22:11:21 +00:00
|
|
|
const char *prefix, int command_line_option,
|
2015-12-16 00:04:12 +00:00
|
|
|
int quiet, int max_parallel_jobs);
|
2016-12-20 23:20:09 +00:00
|
|
|
extern unsigned is_submodule_modified(const char *path, int ignore_untracked);
|
|
|
|
extern int submodule_uses_gitfile(const char *path);
|
2016-12-20 23:20:11 +00:00
|
|
|
|
|
|
|
#define SUBMODULE_REMOVAL_DIE_ON_ERROR (1<<0)
|
|
|
|
#define SUBMODULE_REMOVAL_IGNORE_UNTRACKED (1<<1)
|
|
|
|
#define SUBMODULE_REMOVAL_IGNORE_IGNORED_UNTRACKED (1<<2)
|
|
|
|
extern int bad_to_remove_submodule(const char *path, unsigned flags);
|
2017-05-06 22:09:57 +00:00
|
|
|
extern int merge_submodule(struct object_id *result, const char *path,
|
|
|
|
const struct object_id *base,
|
|
|
|
const struct object_id *a,
|
|
|
|
const struct object_id *b, int search);
|
2017-03-31 01:40:00 +00:00
|
|
|
extern int find_unpushed_submodules(struct oid_array *commits,
|
2016-12-20 23:20:09 +00:00
|
|
|
const char *remotes_name,
|
|
|
|
struct string_list *needs_pushing);
|
2017-03-31 01:40:00 +00:00
|
|
|
extern int push_unpushed_submodules(struct oid_array *commits,
|
2017-04-05 17:47:19 +00:00
|
|
|
const struct remote *remote,
|
|
|
|
const char **refspec, int refspec_nr,
|
2017-04-05 17:47:16 +00:00
|
|
|
const struct string_list *push_options,
|
2016-11-17 18:46:04 +00:00
|
|
|
int dry_run);
|
2016-12-20 23:20:09 +00:00
|
|
|
extern void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
|
|
|
|
extern int parallel_submodules(void);
|
2017-03-26 02:42:30 +00:00
|
|
|
/*
|
|
|
|
* Given a submodule path (as in the index), return the repository
|
|
|
|
* path of that submodule in 'buf'. Return -1 on error or when the
|
|
|
|
* submodule is not initialized.
|
|
|
|
*/
|
|
|
|
int submodule_to_gitdir(struct strbuf *buf, const char *submodule);
|
2009-10-19 12:38:32 +00:00
|
|
|
|
2017-03-14 21:46:37 +00:00
|
|
|
#define SUBMODULE_MOVE_HEAD_DRY_RUN (1<<0)
|
|
|
|
#define SUBMODULE_MOVE_HEAD_FORCE (1<<1)
|
|
|
|
extern int submodule_move_head(const char *path,
|
|
|
|
const char *old,
|
|
|
|
const char *new,
|
|
|
|
unsigned flags);
|
|
|
|
|
2016-04-28 13:38:20 +00:00
|
|
|
/*
|
|
|
|
* Prepare the "env_array" parameter of a "struct child_process" for executing
|
|
|
|
* a submodule by clearing any repo-specific envirionment variables, but
|
submodule: stop sanitizing config options
The point of having a whitelist of command-line config
options to pass to submodules was two-fold:
1. It prevented obvious nonsense like using core.worktree
for multiple repos.
2. It could prevent surprise when the user did not mean
for the options to leak to the submodules (e.g.,
http.sslverify=false).
For case 1, the answer is mostly "if it hurts, don't do
that". For case 2, we can note that any such example has a
matching inverted surprise (e.g., a user who meant
http.sslverify=true to apply everywhere, but it didn't).
So this whitelist is probably not giving us any benefit, and
is already creating a hassle as people propose things to put
on it. Let's just drop it entirely.
Note that we still need to keep a special code path for
"prepare the submodule environment", because we still have
to take care to pass through $GIT_CONFIG_PARAMETERS (and
block the rest of the repo-specific environment variables).
We can do this easily from within the submodule shell
script, which lets us drop the submodule--helper option
entirely (and it's OK to do so because as a "--" program, it
is entirely a private implementation detail).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-05 01:22:19 +00:00
|
|
|
* retaining any config in the environment.
|
2016-04-28 13:38:20 +00:00
|
|
|
*/
|
2016-12-20 23:20:09 +00:00
|
|
|
extern void prepare_submodule_repo_env(struct argv_array *out);
|
2016-04-28 13:38:20 +00:00
|
|
|
|
2016-12-12 19:04:35 +00:00
|
|
|
#define ABSORB_GITDIR_RECURSE_SUBMODULES (1<<0)
|
|
|
|
extern void absorb_git_dir_into_superproject(const char *prefix,
|
|
|
|
const char *path,
|
|
|
|
unsigned flags);
|
2017-03-08 23:07:42 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the absolute path of the working tree of the superproject, which this
|
|
|
|
* project is a submodule of. If this repository is not a submodule of
|
|
|
|
* another repository, return NULL.
|
|
|
|
*/
|
|
|
|
extern const char *get_superproject_working_tree(void);
|
|
|
|
|
2009-10-19 12:38:32 +00:00
|
|
|
#endif
|