From 33b433898ebd7771ca045338bfca7c910312970c Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Wed, 12 Sep 2018 09:57:21 -0400 Subject: Avoid hardlinks when cloning across filesystems Would be nice if git detected this for us, but sadly it doesn't. --- package.inc.sh | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/package.inc.sh b/package.inc.sh index 7a9756d..84c9f66 100644 --- a/package.inc.sh +++ b/package.inc.sh @@ -156,7 +156,7 @@ package_export() { } package_checkout() { - local remote + local remote clone_args pkgname=$1 package_init "$pkgname" remote || return @@ -164,12 +164,20 @@ package_checkout() { git show-ref -q "refs/heads/$remote/packages/$pkgname" || git branch -qf --no-track {,}"$remote/packages/$pkgname" - quiet_git clone \ - --local \ - --single-branch \ - --branch "$remote/packages/$pkgname" \ - --config "pull.rebase=true" \ - "$ASPROOT" "$pkgname" || return + clone_args=( + --local + --single-branch + --branch "$remote/packages/$pkgname" + --config "pull.rebase=true" + ) + + # If the current directory isn't on the same FS as us, then we can't use + # hardlinks in the clone, implied by --local. + if [[ $(stat -c %d "$ASPROOT") != "$(stat -c %d .)" ]] ; then + clone_args+=(--no-hardlinks) + fi + + quiet_git clone "${clone_args[@]}" "$ASPROOT" "$pkgname" } package_get_repos_with_arch() { -- cgit v1.2.3-70-g09d2 From 407848a56e0f5a9073c328d1ed0c915b2f4309f0 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Thu, 13 Sep 2018 06:30:30 -0400 Subject: Revert "Avoid hardlinks when cloning across filesystems" This reverts commit 33b433898ebd7771ca045338bfca7c910312970c. --- package.inc.sh | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/package.inc.sh b/package.inc.sh index 84c9f66..7a9756d 100644 --- a/package.inc.sh +++ b/package.inc.sh @@ -156,7 +156,7 @@ package_export() { } package_checkout() { - local remote clone_args + local remote pkgname=$1 package_init "$pkgname" remote || return @@ -164,20 +164,12 @@ package_checkout() { git show-ref -q "refs/heads/$remote/packages/$pkgname" || git branch -qf --no-track {,}"$remote/packages/$pkgname" - clone_args=( - --local - --single-branch - --branch "$remote/packages/$pkgname" - --config "pull.rebase=true" - ) - - # If the current directory isn't on the same FS as us, then we can't use - # hardlinks in the clone, implied by --local. - if [[ $(stat -c %d "$ASPROOT") != "$(stat -c %d .)" ]] ; then - clone_args+=(--no-hardlinks) - fi - - quiet_git clone "${clone_args[@]}" "$ASPROOT" "$pkgname" + quiet_git clone \ + --local \ + --single-branch \ + --branch "$remote/packages/$pkgname" \ + --config "pull.rebase=true" \ + "$ASPROOT" "$pkgname" || return } package_get_repos_with_arch() { -- cgit v1.2.3-70-g09d2 From d1a652ddd1d56b8f4608e46890f893df2915955f Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Thu, 13 Sep 2018 06:30:50 -0400 Subject: Use --shared instead of --local for clones A second attempt at fixing https://bugs.archlinux.org/task/60027 -- using --shared is much simpler and results in better diskspace savings. --- package.inc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.inc.sh b/package.inc.sh index 7a9756d..1ae9a5b 100644 --- a/package.inc.sh +++ b/package.inc.sh @@ -165,7 +165,7 @@ package_checkout() { git branch -qf --no-track {,}"$remote/packages/$pkgname" quiet_git clone \ - --local \ + --shared \ --single-branch \ --branch "$remote/packages/$pkgname" \ --config "pull.rebase=true" \ -- cgit v1.2.3-70-g09d2 From 95d5b778c411e6365b128f6c19fb99835669461b Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Thu, 13 Sep 2018 20:35:28 -0400 Subject: Fix some shellcheck warnings --- asp.in | 14 +++++++------- util.inc.sh | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/asp.in b/asp.in index 99f69fe..69c3bdc 100644 --- a/asp.in +++ b/asp.in @@ -5,8 +5,8 @@ ARCH_GIT_REPOS=(packages community) OPT_ARCH=$(uname -m) OPT_FORCE=0 -: ${ASPROOT:=${XDG_CACHE_HOME:-$HOME/.cache}/asp} -: ${ASPCACHE:=$ASPROOT/cache} +: "${ASPROOT:=${XDG_CACHE_HOME:-$HOME/.cache}/asp}" +: "${ASPCACHE:=$ASPROOT/cache}" m4_include(util.inc.sh) m4_include(remote.inc.sh) @@ -53,12 +53,12 @@ __require_argc() { local min max argc=$2 case $1 in - *-*) - IFS=- read -r min max <<<"$1" - ;; *-) min=${1%-} ;; + *-*) + IFS=- read -r min max <<<"$1" + ;; *) min=$1 max=$1 ;; @@ -203,7 +203,7 @@ untrack() { disk_usage() { local usage - read usage _ < <(du -sh "$ASPROOT") + read -r usage _ < <(du -sh "$ASPROOT") log_info 'Using %s on disk.' "$usage" } @@ -311,7 +311,7 @@ dispatch_action() { # exact match if declare -F "action__$1" &>/dev/null; then - "action__$@" + "action__$1" "${@:2}" return fi diff --git a/util.inc.sh b/util.inc.sh index 7529eca..3aae736 100644 --- a/util.inc.sh +++ b/util.inc.sh @@ -1,4 +1,5 @@ log_meta() { + # shellcheck disable=SC2059 printf "$1 $2\\n" "${@:3}" } -- cgit v1.2.3-70-g09d2