From 1dfb56380c590d65e8cd313f75cc7cb28841bfc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 5 Mar 2019 23:12:17 +0100 Subject: utils: try to improve git clone to really use git clone --- scripts/utils | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'scripts') 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" } -- cgit v1.2.3