Merge branch 'sb/submodule-blanket-recursive'
Many commands learned to pay attention to submodule.recurse configuration. * sb/submodule-blanket-recursive: builtin/fetch.c: respect 'submodule.recurse' option builtin/push.c: respect 'submodule.recurse' option builtin/grep.c: respect 'submodule.recurse' option Introduce 'submodule.recurse' option for worktree manipulators submodule loading: separate code path for .gitmodules and config overlay reset/checkout/read-tree: unify config callback for submodule recursion submodule test invocation: only pass additional arguments submodule recursing: do not write a config variable twice
This commit is contained in:
@ -24,25 +24,6 @@
|
||||
#include "submodule.h"
|
||||
#include "submodule-config.h"
|
||||
|
||||
static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
|
||||
|
||||
static int option_parse_recurse_submodules(const struct option *opt,
|
||||
const char *arg, int unset)
|
||||
{
|
||||
if (unset) {
|
||||
recurse_submodules = RECURSE_SUBMODULES_OFF;
|
||||
return 0;
|
||||
}
|
||||
if (arg)
|
||||
recurse_submodules =
|
||||
parse_update_recurse_submodules_arg(opt->long_name,
|
||||
arg);
|
||||
else
|
||||
recurse_submodules = RECURSE_SUBMODULES_ON;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char * const git_reset_usage[] = {
|
||||
N_("git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]"),
|
||||
N_("git reset [-q] [<tree-ish>] [--] <paths>..."),
|
||||
@ -284,6 +265,14 @@ static int reset_refs(const char *rev, const struct object_id *oid)
|
||||
return update_ref_status;
|
||||
}
|
||||
|
||||
static int git_reset_config(const char *var, const char *value, void *cb)
|
||||
{
|
||||
if (!strcmp(var, "submodule.recurse"))
|
||||
return git_default_submodule_config(var, value, cb);
|
||||
|
||||
return git_default_config(var, value, cb);
|
||||
}
|
||||
|
||||
int cmd_reset(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
int reset_type = NONE, update_ref_status = 0, quiet = 0;
|
||||
@ -303,26 +292,22 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
|
||||
N_("reset HEAD, index and working tree"), MERGE),
|
||||
OPT_SET_INT(0, "keep", &reset_type,
|
||||
N_("reset HEAD but keep local changes"), KEEP),
|
||||
{ OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules,
|
||||
{ OPTION_CALLBACK, 0, "recurse-submodules", NULL,
|
||||
"reset", "control recursive updating of submodules",
|
||||
PARSE_OPT_OPTARG, option_parse_recurse_submodules },
|
||||
PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater },
|
||||
OPT_BOOL('p', "patch", &patch_mode, N_("select hunks interactively")),
|
||||
OPT_BOOL('N', "intent-to-add", &intent_to_add,
|
||||
N_("record only the fact that removed paths will be added later")),
|
||||
OPT_END()
|
||||
};
|
||||
|
||||
git_config(git_default_config, NULL);
|
||||
git_config(git_reset_config, NULL);
|
||||
|
||||
argc = parse_options(argc, argv, prefix, options, git_reset_usage,
|
||||
PARSE_OPT_KEEP_DASHDASH);
|
||||
parse_args(&pathspec, argv, prefix, patch_mode, &rev);
|
||||
|
||||
if (recurse_submodules != RECURSE_SUBMODULES_DEFAULT) {
|
||||
gitmodules_config();
|
||||
git_config(submodule_config, NULL);
|
||||
set_config_update_recurse_submodules(RECURSE_SUBMODULES_ON);
|
||||
}
|
||||
load_submodule_cache();
|
||||
|
||||
unborn = !strcmp(rev, "HEAD") && get_sha1("HEAD", oid.hash);
|
||||
if (unborn) {
|
||||
|
Reference in New Issue
Block a user