aboutsummaryrefslogtreecommitdiff
path: root/kiss
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2020-02-19 13:26:33 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2020-02-19 13:26:33 +0000
commit027b4915ea60fb7277cfce452b1aaff02c40d92b (patch)
treea1309756e8ee7b7d817a5c2125323bd4a7d26a92 /kiss
parent524c4ac8717ba99f88d5ad938829e1dea79e0ac2 (diff)
downloadcpt-027b4915ea60fb7277cfce452b1aaff02c40d92b.tar.gz
kiss: less git pulls
FossilOrigin-Name: 4609ec83ae5ceef9672d31fa7840002f7cffc977d5eecb6c4d25ef96d1720e83
Diffstat (limited to 'kiss')
-rwxr-xr-xkiss29
1 files changed, 24 insertions, 5 deletions
diff --git a/kiss b/kiss
index d59fc99..f698c13 100755
--- a/kiss
+++ b/kiss
@@ -193,10 +193,16 @@ pkg_sources() {
log "$1" "Cloning ${repo_src%#*}"
- [ "${src##*#*}" ] && shallow=--depth=1
-
+ # If a commit hash or branch was given, grab the latest
+ # commit from all branches. This gives a speed-up when
+ # wanting to checkout a specific branch.
+ [ "${src##*#*}" ] ||
+ branch=--no-single-branch
+
+ # Always do a shallow clone as we will unshallow it if
+ # needed later (when a commit is desired).
cd "$mak_dir/$1/$dest" &&
- git clone "${shallow:---}" "${repo_src%#*}" .
+ git clone --depth=1 "${branch:---}" "${repo_src%#*}" .
) || die "$1" "Failed to clone $src"
@@ -234,8 +240,21 @@ pkg_extract() {
git+*\#*)
log "Checking out ${src##*#}"
- git -c advice.detachedHead=false checkout "${src##*#}" ||
- die "Commit hash ${src##*#} doesn't exist"
+ (
+ set -- git -c advice.detachedHead=false checkout
+
+ # Try to checkout the commit or branch. If it fails,
+ # unshallow the repository as we're dealing with a
+ # specific commit.
+ "$@" "${src##*#}" >/dev/null 2>&1 ||
+ git fetch --unshallow
+
+ # Checkout the repository a second time. If this
+ # fails, the desired commit or branch doesn't exist.
+ # This will do nothing if the above checkout succeeded.
+ "$@" "${src##*#}" 2>/dev/null ||
+ die "${src##*#} doesn't exist"
+ )
;;
# Git repository, comment or blank line.