Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtharva Raykar <raykar.ath@gmail.com>2021-08-06 17:04:31 +0300
committerJunio C Hamano <gitster@pobox.com>2021-08-10 20:57:57 +0300
commita452128a36cb73f5366c23eabe93c7edfa227866 (patch)
treeffad56bf1145c48e1bd64c73a2d642df972745ad /git-submodule.sh
parentbbe3165f825c8d9b6e4a6747a287147b4583c3c1 (diff)
submodule--helper: introduce add-config subcommand
Add a new "add-config" subcommand to `git submodule--helper` with the goal of converting part of the shell code in git-submodule.sh related to `git submodule add` into C code. This new subcommand sets the configuration variables of a newly added submodule, by registering the url in local git config, as well as the submodule name and path in the .gitmodules file. It also sets 'submodule.<name>.active' to "true" if the submodule path has not already been covered by any pathspec specified in 'submodule.active'. This is meant to be a faithful conversion from shell to C, although we add comments to areas that could be improved in future patches, after the conversion has settled. Signed-off-by: Atharva Raykar <raykar.ath@gmail.com> Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Shourya Shukla <periperidip@gmail.com> Based-on-patch-by: Shourya Shukla <periperidip@gmail.com> Based-on-patch-by: Prathamesh Chavan <pc44800@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh28
1 files changed, 1 insertions, 27 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 053daf3724..f713cb113c 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -242,33 +242,7 @@ cmd_add()
fi
git submodule--helper add-clone ${GIT_QUIET:+--quiet} ${force:+"--force"} ${progress:+"--progress"} ${branch:+--branch "$branch"} --prefix "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" ${reference:+"$reference"} ${dissociate:+"--dissociate"} ${depth:+"$depth"} || exit
- git config submodule."$sm_name".url "$realrepo"
-
- git add --no-warn-embedded-repo $force "$sm_path" ||
- die "fatal: $(eval_gettext "Failed to add submodule '\$sm_path'")"
-
- git submodule--helper config submodule."$sm_name".path "$sm_path" &&
- git submodule--helper config submodule."$sm_name".url "$repo" &&
- if test -n "$branch"
- then
- git submodule--helper config submodule."$sm_name".branch "$branch"
- fi &&
- git add --force .gitmodules ||
- die "fatal: $(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
+ git submodule--helper add-config ${force:+--force} ${branch:+--branch "$branch"} --url "$repo" --resolved-url "$realrepo" --path "$sm_path" --name "$sm_name"
}
#