From: Oleg Broytman Date: Tue, 12 May 2020 10:52:27 +0000 (+0300) Subject: Feat(sparse-clone): Validate parameters X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=0fae62228c817ff60536eef5f975516bdccd58fa;p=git-scripts.git Feat(sparse-clone): Validate parameters --- diff --git a/sparse-clone b/sparse-clone index 5bbaa6b..0037a86 100755 --- a/sparse-clone +++ b/sparse-clone @@ -2,15 +2,20 @@ # Adapted from https://stackoverflow.com/a/13738951/7976758 set -e -rurl="$1" -localdir="$2" +if [ -z "$3" ]; then + echo "Usage: $0 origin local patterns..." >&2 + exit 1 +fi + +origin="$1" +local_repo="$2" shift 2 -mkdir -p "$localdir" -cd "$localdir" +mkdir -p "$local_repo" +cd "$local_repo" git init -git remote add origin "$rurl" +git remote add origin "$origin" git config core.sparseCheckout true