From 027b4915ea60fb7277cfce452b1aaff02c40d92b Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Wed, 19 Feb 2020 13:26:33 +0000 Subject: kiss: less git pulls FossilOrigin-Name: 4609ec83ae5ceef9672d31fa7840002f7cffc977d5eecb6c4d25ef96d1720e83 --- kiss | 29 ++++++++++++++++++++++++----- 1 file 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. -- cgit v1.2.3 From 431522e3e711803c87d27ef935831541b0d6d91f Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Wed, 19 Feb 2020 14:11:02 +0000 Subject: kiss: shallow branch support FossilOrigin-Name: 0f36586c97a34cfa6d4df3cb3deb9d206e2b186026c7410835462f43f6aa8257 --- kiss | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/kiss b/kiss index f698c13..1aed25d 100755 --- a/kiss +++ b/kiss @@ -187,22 +187,27 @@ 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%[@#]*}" - # 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 + # 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 + + # 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 -- || + set -- -b "${src##*@}" "${repo_src%@*}" # 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 --depth=1 "${branch:---}" "${repo_src%#*}" . + git clone --depth=1 "${@:-${repo_src%#*}}" . ) || die "$1" "Failed to clone $src" @@ -241,19 +246,15 @@ pkg_extract() { log "Checking out ${src##*#}" ( - 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" + # 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" ) ;; -- cgit v1.2.3 From 56a6186d072aba6d1ada877603644087c0bce216 Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Wed, 19 Feb 2020 14:13:15 +0000 Subject: kiss: remove left over subshell FossilOrigin-Name: af96535e6ab9491467fe91f85bfecde2360e930cc4fc2062d3efa0f6e96f97dc --- kiss | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/kiss b/kiss index 1aed25d..a59a502 100755 --- a/kiss +++ b/kiss @@ -245,17 +245,15 @@ 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" - ) + # 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" ;; # Git repository, comment or blank line. -- cgit v1.2.3 From 929283edb08cbe965637c033ac32c93a243044ea Mon Sep 17 00:00:00 2001 From: "dylan.araps@gmail.com" Date: Wed, 19 Feb 2020 14:28:43 +0000 Subject: kiss: Fix old behavior FossilOrigin-Name: 4ed7c978a2ca59433dd20757bd2eb73b0d069188109dd8e914975822206a9d98 --- kiss | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/kiss b/kiss index a59a502..956d2d5 100755 --- a/kiss +++ b/kiss @@ -199,15 +199,27 @@ pkg_sources() { # beforehand. cd "$mak_dir/$1/$dest" || die 2>/dev/null + # 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 -- || + [ "${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 "${@:-${repo_src%#*}}" . + git clone --depth=1 "$@" . ) || die "$1" "Failed to clone $src" -- cgit v1.2.3