submodule--helper init: set submodule.<name>.active
When initializing a submodule set the submodule.<name>.active config to true if the module hasn't already been configured to be active by some other means (e.g. a pathspec set in submodule.active). Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Mar 17, 2017 at 15:38 UTC
1f8d711548c08e05766e067dc23e5be3b1b72657
2 files changed
+23
builtin/submodule--helper.c
+12
@@ -356,6 +356,18 @@ static void init_submodule(const char *path, const char *prefix, int quiet)
356
die(_("No url found for submodule path '%s' in .gitmodules"),
357
displaypath);
358
359
+ /*
360
+ * NEEDSWORK: In a multi-working-tree world, this needs to be
361
+ * set in the per-worktree config.
362
+ *
363
+ * Set active flag for the submodule being initialized
364
+ */
365
+ if (!is_submodule_initialized(path)) {
366
+ strbuf_reset(&sb);
367
+ strbuf_addf(&sb, "submodule.%s.active", sub->name);
368
+ git_config_set_gently(sb.buf, "true");
369
+ }
370
+
371
/*
372
* Copy url setting when it is not set yet.
373
* To look up the url in .git/config, we must not fall back to
t/t7400-submodule-basic.sh
+11
@@ -1256,4 +1256,15 @@ test_expect_success 'clone and subsequent updates correctly auto-initialize subm
1256
test_cmp expect2 actual
1257
'
1258
1259
+test_expect_success 'init properly sets the config' '
1260
+ test_when_finished "rm -rf multisuper_clone" &&
1261
+ git clone --recurse-submodules="." \
1262
+ --recurse-submodules=":(exclude)sub0" \
1263
+ multisuper multisuper_clone &&
1264
+
1265
+ git -C multisuper_clone submodule init -- sub0 sub1 &&
1266
+ git -C multisuper_clone config --get submodule.sub0.active &&
1267
+ test_must_fail git -C multisuper_clone config --get submodule.sub1.active
1268
+'
1269
+
1270
test_done