@@ -40,7 +40,6 @@ static const char * const builtin_branch_usage[] = {
static const char *head;
static struct object_id head_oid;
static int recurse_submodules = 0;
-static int submodule_propagate_branches = 0;
static int branch_use_color = -1;
static char branch_colors[][COLOR_MAXLEN] = {
@@ -106,10 +105,6 @@ static int git_branch_config(const char *var, const char *value, void *cb)
recurse_submodules = git_config_bool(var, value);
return 0;
}
- if (!strcasecmp(var, "submodule.propagateBranches")) {
- submodule_propagate_branches = git_config_bool(var, value);
- return 0;
- }
return git_color_default_config(var, value, cb);
}
@@ -714,7 +709,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, options, builtin_branch_usage,
0);
-
+ prepare_repo_settings(the_repository);
if (!delete && !rename && !copy && !edit_description && !new_upstream &&
!show_current && !unset_upstream && argc == 0)
list = 1;
@@ -730,7 +725,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
usage_with_options(builtin_branch_usage, options);
if (recurse_submodules_explicit) {
- if (!submodule_propagate_branches)
+ if (!the_repository->settings.submodule_propagate_branches)
die(_("branch with --recurse-submodules can only be used if submodule.propagateBranches is enabled"));
if (noncreate_actions)
die(_("--recurse-submodules can only be used to create branches"));
@@ -738,7 +733,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
recurse_submodules =
(recurse_submodules || recurse_submodules_explicit) &&
- submodule_propagate_branches;
+ the_repository->settings.submodule_propagate_branches;
if (filter.abbrev == -1)
filter.abbrev = DEFAULT_ABBREV;
@@ -505,6 +505,7 @@ static inline enum object_type object_type(unsigned int mode)
#define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE"
#define GIT_PREFIX_ENVIRONMENT "GIT_PREFIX"
#define GIT_SUPER_PREFIX_ENVIRONMENT "GIT_INTERNAL_SUPER_PREFIX"
+#define GIT_SUBMODULE_PROPAGATE_BRANCHES_ENVIRONMENT "GIT_INTERNAL_SUBMODULE_PROPAGATE_BRANCHES"
#define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
#define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
#define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
@@ -60,16 +60,17 @@ void prepare_repo_settings(struct repository *r)
repo_cfg_bool(r, "pack.usesparse", &r->settings.pack_use_sparse, 1);
repo_cfg_bool(r, "core.multipackindex", &r->settings.core_multi_pack_index, 1);
repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0);
+ repo_cfg_bool(r, "submodule.propagateBranches", &r->settings.submodule_propagate_branches, 0);
/*
- * The GIT_TEST_MULTI_PACK_INDEX variable is special in that
- * either it *or* the config sets
- * r->settings.core_multi_pack_index if true. We don't take
- * the environment variable if it exists (even if false) over
- * any config, as in most other cases.
+ * Boolean settings from config and environment variables. Only
+ * take the environment variable if it is true, otherwise, use
+ * the config.
*/
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0))
r->settings.core_multi_pack_index = 1;
+ if (git_env_bool(GIT_SUBMODULE_PROPAGATE_BRANCHES_ENVIRONMENT, 0))
+ r->settings.submodule_propagate_branches = 1;
/*
* Non-boolean config
@@ -36,6 +36,7 @@ struct repo_settings {
int fetch_write_commit_graph;
int command_requires_full_index;
int sparse_index;
+ int submodule_propagate_branches;
struct fsmonitor_settings *fsmonitor; /* lazily loaded */
@@ -504,6 +504,8 @@ static void print_submodule_diff_summary(struct repository *r, struct rev_info *
void prepare_submodule_repo_env(struct strvec *out)
{
+ if (the_repository->settings.submodule_propagate_branches)
+ strvec_pushf(out, "%s=1", GIT_SUBMODULE_PROPAGATE_BRANCHES_ENVIRONMENT);
prepare_other_repo_env(out, DEFAULT_GIT_DIR_ENVIRONMENT);
}