aboutsummaryrefslogtreecommitdiff
path: root/kiss
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2020-02-19 16:22:49 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2020-02-19 16:22:49 +0000
commitb66580b8bb2cd27f179c4ccd2ed6fbda72d824ef (patch)
tree8f3928f1d50070a0597478071d76c31aa8f8b76d /kiss
parent7afc97a0639d66c7dfdf2f3f4393d3e320dd9604 (diff)
parent11ef2019d9298a36385561e51c176b3c96ea87e5 (diff)
downloadcpt-b66580b8bb2cd27f179c4ccd2ed6fbda72d824ef.tar.gz
Merge branch 'master' of github.com:kissx/kiss
FossilOrigin-Name: d5e9fdf71790b099cc2881dbd970f220f6bbb1a2fa498bb6a1898b4f936bf81b
Diffstat (limited to 'kiss')
-rwxr-xr-xkiss40
1 files changed, 35 insertions, 5 deletions
diff --git a/kiss b/kiss
index bbe6884..4fef438 100755
--- a/kiss
+++ b/kiss
@@ -187,16 +187,39 @@ pkg_sources() {
mkdir -p "$mak_dir/$1/$dest"
- # Run in a subshell to keep variables local.
+ # Run in a subshell to keep the variables, path and
+ # argument list local to each loop iteration.
(
repo_src=${src##git+}
- log "$1" "Cloning ${repo_src%#*}"
+ log "$1" "Cloning ${repo_src%[@#]*}"
- [ "${src##*#*}" ] && shallow=--depth=1
+ # Git has no option to clone a repository to a
+ # specific location so we must do it ourselves
+ # beforehand.
+ cd "$mak_dir/$1/$dest" || die 2>/dev/null
- cd "$mak_dir/$1/$dest" &&
- git clone "${shallow:---}" "${repo_src%#*}" .
+ # Clear the argument list as we'll be overwriting
+ # it below based on what kind of checkout we're
+ # dealing with.
+ set -- "$repo_src"
+
+ # If a branch was given, shallow clone it directly.
+ # This speeds things up as we don't have to grab
+ # a lot of unneeded commits.
+ [ "${src##*@*}" ] ||
+ set -- -b "${src##*@}" "${repo_src%@*}"
+
+ # Maintain compatibility with older versions of
+ # kiss by shallow cloning all branches. This has
+ # the added benefit of allowing checkouts of
+ # specific commits in specific branches.
+ [ "${src##*#*}" ] ||
+ set -- --no-single-branch "${repo_src%#*}"
+
+ # Always do a shallow clone as we will unshallow it if
+ # needed later (when a commit is desired).
+ git clone --depth=1 "$@" .
) || die "$1" "Failed to clone $src"
@@ -234,6 +257,13 @@ pkg_extract() {
git+*\#*)
log "Checking out ${src##*#}"
+ # A commit was requested, unshallow the repository.
+ # This will convert it to a regular repository with
+ # full history.
+ git fetch --unshallow
+
+ # Try to checkout the repository. If we fail here,
+ # the requested commit doesn't exist.
git -c advice.detachedHead=false checkout "${src##*#}" ||
die "Commit hash ${src##*#} doesn't exist"
;;