Skip to content

Commit

Permalink
submodule--helper init: set submodule.<name>.active
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bmwill authored and gitster committed Mar 18, 2017
1 parent bb62e0a commit 1f8d711
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions builtin/submodule--helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,18 @@ static void init_submodule(const char *path, const char *prefix, int quiet)
die(_("No url found for submodule path '%s' in .gitmodules"),
displaypath);

/*
* NEEDSWORK: In a multi-working-tree world, this needs to be
* set in the per-worktree config.
*
* Set active flag for the submodule being initialized
*/
if (!is_submodule_initialized(path)) {
strbuf_reset(&sb);
strbuf_addf(&sb, "submodule.%s.active", sub->name);
git_config_set_gently(sb.buf, "true");
}

/*
* Copy url setting when it is not set yet.
* To look up the url in .git/config, we must not fall back to
Expand Down
11 changes: 11 additions & 0 deletions t/t7400-submodule-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1256,4 +1256,15 @@ test_expect_success 'clone and subsequent updates correctly auto-initialize subm
test_cmp expect2 actual
'

test_expect_success 'init properly sets the config' '
test_when_finished "rm -rf multisuper_clone" &&
git clone --recurse-submodules="." \
--recurse-submodules=":(exclude)sub0" \
multisuper multisuper_clone &&
git -C multisuper_clone submodule init -- sub0 sub1 &&
git -C multisuper_clone config --get submodule.sub0.active &&
test_must_fail git -C multisuper_clone config --get submodule.sub1.active
'

test_done

0 comments on commit 1f8d711

Please sign in to comment.