зеркало из https://github.com/microsoft/git.git
git-submodule: move cloning into a separate function
This is just a simple refactoring of modules_init() with no change in functionality. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
6abd0fb396
Коммит
33aa6fff5d
|
@ -25,20 +25,14 @@ say()
|
|||
fi
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Run clone + checkout on missing submodules
|
||||
# Clone a submodule
|
||||
#
|
||||
# $@ = requested paths (default to all)
|
||||
#
|
||||
modules_init()
|
||||
module_clone()
|
||||
{
|
||||
git ls-files --stage -- "$@" | grep -e '^160000 ' |
|
||||
while read mode sha1 stage path
|
||||
do
|
||||
# Skip submodule paths that already contain a .git directory.
|
||||
# This will also trigger if $path is a symlink to a git
|
||||
# repository
|
||||
test -d "$path"/.git && continue
|
||||
path=$1
|
||||
url=$2
|
||||
|
||||
# If there already is a directory at the submodule path,
|
||||
# expect it to be empty (since that is the default checkout
|
||||
|
@ -54,6 +48,25 @@ modules_init()
|
|||
test -e "$path" &&
|
||||
die "A file already exist at path '$path'"
|
||||
|
||||
git-clone -n "$url" "$path" ||
|
||||
die "Clone of submodule '$path' failed"
|
||||
}
|
||||
|
||||
#
|
||||
# Run clone + checkout on missing submodules
|
||||
#
|
||||
# $@ = requested paths (default to all)
|
||||
#
|
||||
modules_init()
|
||||
{
|
||||
git ls-files --stage -- "$@" | grep -e '^160000 ' |
|
||||
while read mode sha1 stage path
|
||||
do
|
||||
# Skip submodule paths that already contain a .git directory.
|
||||
# This will also trigger if $path is a symlink to a git
|
||||
# repository
|
||||
test -d "$path"/.git && continue
|
||||
|
||||
url=$(GIT_CONFIG=.gitmodules git-config module."$path".url)
|
||||
test -z "$url" &&
|
||||
die "No url found for submodule '$path' in .gitmodules"
|
||||
|
@ -69,8 +82,7 @@ modules_init()
|
|||
# logical modulename (if present) as key. But this would need
|
||||
# another fallback mechanism if the module wasn't named.
|
||||
|
||||
git-clone -n "$url" "$path" ||
|
||||
die "Clone of submodule '$path' failed"
|
||||
module_clone "$path" "$url" || exit
|
||||
|
||||
(unset GIT_DIR && cd "$path" && git-checkout -q "$sha1") ||
|
||||
die "Checkout of submodule '$path' failed"
|
||||
|
|
Загрузка…
Ссылка в новой задаче