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