2009-10-19 16:38:32 +04:00
|
|
|
#ifndef SUBMODULE_H
|
|
|
|
#define SUBMODULE_H
|
|
|
|
|
2010-06-25 18:56:47 +04:00
|
|
|
struct diff_options;
|
2012-09-01 19:27:06 +04:00
|
|
|
struct argv_array;
|
2010-06-25 18:56:47 +04:00
|
|
|
|
2011-03-07 01:10:46 +03:00
|
|
|
enum {
|
2015-11-17 14:05:56 +03:00
|
|
|
RECURSE_SUBMODULES_CHECK = -4,
|
2015-08-18 03:22:00 +03:00
|
|
|
RECURSE_SUBMODULES_ERROR = -3,
|
2015-08-18 03:21:57 +03:00
|
|
|
RECURSE_SUBMODULES_NONE = -2,
|
2011-03-07 01:10:46 +03:00
|
|
|
RECURSE_SUBMODULES_ON_DEMAND = -1,
|
|
|
|
RECURSE_SUBMODULES_OFF = 0,
|
|
|
|
RECURSE_SUBMODULES_DEFAULT = 1,
|
|
|
|
RECURSE_SUBMODULES_ON = 2
|
|
|
|
};
|
|
|
|
|
2016-03-01 05:07:11 +03: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 05:07:13 +03:00
|
|
|
#define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED, NULL}
|
2016-03-01 05:07:11 +03:00
|
|
|
|
2013-07-30 23:50:34 +04:00
|
|
|
int is_staging_gitmodules_ok(void);
|
2013-08-06 23:15:11 +04:00
|
|
|
int update_path_in_gitmodules(const char *oldpath, const char *newpath);
|
2013-08-06 23:15:25 +04:00
|
|
|
int remove_path_from_gitmodules(const char *path);
|
2013-07-30 23:50:34 +04:00
|
|
|
void stage_updated_gitmodules(void);
|
2010-08-06 02:39:25 +04:00
|
|
|
void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
|
|
|
|
const char *path);
|
2010-11-12 15:54:52 +03:00
|
|
|
int submodule_config(const char *var, const char *value, void *cb);
|
2012-04-10 23:10:26 +04:00
|
|
|
void gitmodules_config(void);
|
2016-03-01 05:07:11 +03:00
|
|
|
int parse_submodule_update_strategy(const char *value,
|
|
|
|
struct submodule_update_strategy *dst);
|
submodule: port init from shell to C
By having the `submodule init` functionality in C, we can reference it
easier from other parts in the code in later patches. The code is split
up to have one function to initialize one submodule and a calling function
that takes care of the rest, such as argument handling and translating the
arguments to the paths of the submodules.
This is the first submodule subcommand that is fully converted to C
except for the usage string, so this is actually removing a call to
the `submodule--helper list` function, which is supposed to be used in
this transition. Instead we'll make a direct call to `module_list_compute`.
An explanation why we need to edit the prefixes in cmd_update in
git-submodule.sh in this patch:
By having no processing in the shell part, we need to convey the notion
of wt_prefix and prefix to the C parts, which former patches punted on
and did the processing of displaying path in the shell.
`wt_prefix` used to hold the path from the repository root to the current
directory, e.g. wt_prefix would be t/ if the user invoked the
`git submodule` command in ~/repo/t and ~repo is the GIT_DIR.
`prefix` used to hold the relative path from the repository root to the
operation, e.g. if you have recursive submodules, the shell script would
modify the `prefix` in each recursive step by adding the submodule path.
We will pass `wt_prefix` into the C helper via `git -C <dir>` as that
will setup git in the directory the user actually called git-submodule.sh
from. The `prefix` will be passed in via the `--prefix` option.
Having `prefix` and `wt_prefix` relative to the GIT_DIR of the
calling superproject is unfortunate with this patch as the C code doesn't
know about a possible recursion from a superproject via `submodule update
--init --recursive`.
To fix this, we change the meaning of `wt_prefix` to point to the current
project instead of the superproject and `prefix` to include any relative
paths issues in the superproject. That way `prefix` will become the leading
part for displaying paths and `wt_prefix` will be empty in recursive
calls for now.
The new notion of `wt_prefix` and `prefix` still allows us to reconstruct
the calling directory in the superproject by just traveling reverse of
`prefix`.
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-04-16 03:50:13 +03:00
|
|
|
const char *submodule_strategy_to_string(const struct submodule_update_strategy *s);
|
2010-06-25 18:56:47 +04:00
|
|
|
void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
|
2009-10-19 16:38:32 +04:00
|
|
|
void show_submodule_summary(FILE *f, const char *path,
|
2013-04-05 20:12:08 +04:00
|
|
|
const char *line_prefix,
|
2009-10-19 16:38:32 +04:00
|
|
|
unsigned char one[20], unsigned char two[20],
|
2012-11-13 19:42:47 +04:00
|
|
|
unsigned dirty_submodule, const char *meta,
|
2009-10-19 16:38:32 +04:00
|
|
|
const char *del, const char *add, const char *reset);
|
2010-11-11 02:55:02 +03:00
|
|
|
void set_config_fetch_recurse_submodules(int value);
|
2011-03-07 01:10:46 +03:00
|
|
|
void check_for_new_submodule_commits(unsigned char new_sha1[20]);
|
2012-09-01 19:27:06 +04:00
|
|
|
int fetch_populated_submodules(const struct argv_array *options,
|
2011-03-07 01:11:21 +03:00
|
|
|
const char *prefix, int command_line_option,
|
2015-12-16 03:04:12 +03:00
|
|
|
int quiet, int max_parallel_jobs);
|
2010-03-14 01:00:27 +03:00
|
|
|
unsigned is_submodule_modified(const char *path, int ignore_untracked);
|
2012-09-26 22:21:13 +04:00
|
|
|
int submodule_uses_gitfile(const char *path);
|
|
|
|
int ok_to_remove_submodule(const char *path);
|
2010-07-07 17:39:13 +04:00
|
|
|
int merge_submodule(unsigned char result[20], const char *path, const unsigned char base[20],
|
2011-10-13 16:59:05 +04:00
|
|
|
const unsigned char a[20], const unsigned char b[20], int search);
|
2012-03-29 11:21:23 +04:00
|
|
|
int find_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name,
|
|
|
|
struct string_list *needs_pushing);
|
2012-03-29 11:21:24 +04:00
|
|
|
int push_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_name);
|
2013-07-30 23:50:03 +04:00
|
|
|
void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
|
2016-03-01 05:07:13 +03:00
|
|
|
int parallel_submodules(void);
|
2009-10-19 16:38:32 +04:00
|
|
|
|
2016-04-28 16:38:20 +03: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 04:22:19 +03:00
|
|
|
* retaining any config in the environment.
|
2016-04-28 16:38:20 +03:00
|
|
|
*/
|
|
|
|
void prepare_submodule_repo_env(struct argv_array *out);
|
|
|
|
|
2009-10-19 16:38:32 +04:00
|
|
|
#endif
|