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-07-10 10:48:01 +0300
committerJunio C Hamano <gitster@pobox.com>2021-07-12 22:06:21 +0300
commit8c8195e9c3e21922673575828977845b613c3491 (patch)
tree88986fff122a27a99b1e38dc5c5dc40c10b44db4 /git-submodule.sh
parenta98b02c11289879868dd0d5f80e894d8d01dc73b (diff)
submodule--helper: introduce add-clone subcommand
Let's add a new "add-clone" 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 clones the repository that is to be added, and checks out to the appropriate branch. This is meant to be a faithful conversion that leaves the behaviour of 'cmd_add()' script unchanged. 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> Helped-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh38
1 files changed, 1 insertions, 37 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 69bcb4fab2..053daf3724 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -241,43 +241,7 @@ cmd_add()
die "fatal: $(eval_gettext "'$sm_name' is not a valid submodule name")"
fi
- # perhaps the path exists and is already a git repo, else clone it
- if test -e "$sm_path"
- then
- if test -d "$sm_path"/.git || test -f "$sm_path"/.git
- then
- eval_gettextln "Adding existing repo at '\$sm_path' to the index"
- else
- die "$(eval_gettext "'\$sm_path' already exists and is not a valid git repo")"
- fi
-
- else
- if test -d ".git/modules/$sm_name"
- then
- if test -z "$force"
- then
- eval_gettextln >&2 "A git directory for '\$sm_name' is found locally with remote(s):"
- GIT_DIR=".git/modules/$sm_name" GIT_WORK_TREE=. git remote -v | grep '(fetch)' | sed -e s,^," ", -e s,' (fetch)',, >&2
- die "$(eval_gettextln "\
-If you want to reuse this local git directory instead of cloning again from
- \$realrepo
-use the '--force' option. If the local git directory is not the correct repo
-or you are unsure what this means choose another name with the '--name' option.")"
- else
- eval_gettextln "Reactivating local git directory for submodule '\$sm_name'."
- fi
- fi
- git submodule--helper clone ${GIT_QUIET:+--quiet} ${progress:+"--progress"} --prefix "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" ${reference:+"$reference"} ${dissociate:+"--dissociate"} ${depth:+"$depth"} || exit
- (
- sanitize_submodule_env
- cd "$sm_path" &&
- # ash fails to wordsplit ${branch:+-b "$branch"...}
- case "$branch" in
- '') git checkout -f -q ;;
- ?*) git checkout -f -q -B "$branch" "origin/$branch" ;;
- esac
- ) || die "$(eval_gettext "Unable to checkout submodule '\$sm_path'")"
- 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" ||