From 1b614c07d2428927358cc7317622913d1dbd59c9 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Fri, 17 Mar 2017 15:38:05 -0700 Subject: submodule add: respect submodule.active and submodule..active In addition to adding submodule..url to the config, set submodule..active to true unless submodule.active is configured and the submodule's path matches the configured pathspec. Signed-off-by: Brandon Williams Signed-off-by: Junio C Hamano --- git-submodule.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'git-submodule.sh') diff --git a/git-submodule.sh b/git-submodule.sh index db94dea3b0..6ec35e5fcd 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -278,6 +278,20 @@ or you are unsure what this means choose another name with the '--name' option." fi && git add --force .gitmodules || die "$(eval_gettext "Failed to register submodule '\$sm_path'")" + + # NEEDSWORK: In a multi-working-tree world, this needs to be + # set in the per-worktree config. + if git config --get submodule.active >/dev/null + then + # If the submodule being adding isn't already covered by the + # current configured pathspec, set the submodule's active flag + if ! git submodule--helper is-active "$sm_path" + then + git config submodule."$sm_name".active "true" + fi + else + git config submodule."$sm_name".active "true" + fi } # -- cgit v1.2.1