summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2019-03-05 23:12:17 +0100
committerKarel Kočí <cynerd@email.cz>2019-03-05 23:12:17 +0100
commit1dfb56380c590d65e8cd313f75cc7cb28841bfc9 (patch)
tree72ec8330d9c5140acfb1891a4ad0c388eb632e0f /scripts
parentf7ac077009bccd9257bc5e4b35631a261c1ece80 (diff)
downloadlaminar-cnf-1dfb56380c590d65e8cd313f75cc7cb28841bfc9.tar.gz
laminar-cnf-1dfb56380c590d65e8cd313f75cc7cb28841bfc9.tar.bz2
laminar-cnf-1dfb56380c590d65e8cd313f75cc7cb28841bfc9.zip
utils: try to improve git clone to really use git clone
Diffstat (limited to 'scripts')
-rw-r--r--scripts/utils20
1 files changed, 7 insertions, 13 deletions
diff --git a/scripts/utils b/scripts/utils
index 1c56d1d..709cace 100644
--- a/scripts/utils
+++ b/scripts/utils
@@ -36,11 +36,11 @@ git_fetch_bare() {
# Common function for git_fetch_{w,g}
# Additional fourth argument should be base path to git mirror
_git_fetch() {
- local BRANCH="$3"
- [ -n "$BRANCH" ] || BRANCH=master
+ local branch="$3"
+ [ -n "$branch" ] || branch=master
git_fetch_bare "$1" "$4/$2"
git --git-dir="$4/$2" --bare worktree prune # remove old work trees
- git --git-dir="$4/$2" --bare worktree add --force --detach "$2" "$BRANCH"
+ git --git-dir="$4/$2" --bare worktree add --force --detach "$2" "$branch"
}
# Fetch git repository with mirror
@@ -67,14 +67,8 @@ git_fetch_g() {
# Second argument is optional and should be branch name (master is used if not
# provided).
git_clone() {
- local BRANCH="$3"
- [ -n "$BRANCH" ] || BRANCH=master
- (
- mkdir "$2"
- cd "$2"
- git init
- git remote add origin "$1"
- git fetch --depth 1 origin "$BRANCH"
- git checkout FETCH_HEAD
- )
+ local src="$1"
+ local dir="$2"
+ local branch="${3:-master}"
+ git clone --depth 1 --branch "$branch" --recurse-submodules "$src" "$dir"
}