diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/utils | 20 |
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" } |