From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CB3E1158041 for ; Mon, 1 Apr 2024 09:40:57 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D0F03E2A23; Mon, 1 Apr 2024 09:40:56 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id AFC4DE2A23 for ; Mon, 1 Apr 2024 09:40:56 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9FE193431AA for ; Mon, 1 Apr 2024 09:40:55 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0F702DC3 for ; Mon, 1 Apr 2024 09:40:54 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1711964188.e686f42afb87ef04362e6c24968d5050e6bb5c91.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/git-r3.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: e686f42afb87ef04362e6c24968d5050e6bb5c91 X-VCS-Branch: master Date: Mon, 1 Apr 2024 09:40:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 3bb54075-d630-48ba-9a73-3d3147200183 X-Archives-Hash: 2bc71582c39889e797eb9d1e58dba11e commit: e686f42afb87ef04362e6c24968d5050e6bb5c91 Author: Sebastian Parborg gmail com> AuthorDate: Mon Mar 25 15:08:41 2024 +0000 Commit: Michał Górny gentoo org> CommitDate: Mon Apr 1 09:36:28 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e686f42a git-r3.eclass: Fix fetching git lfs files at certain refs. Only prune when needed. If a lfs files was changed between the checked out ref and the git head commit, it would fail to fetch them. Now correctly specify the ref for the lfs fetch as well to ensure that we can fetch the correct lfs files. Only prune when we have existing lfs files. For bigger repos with submodules, it will be quite slow to try to prune. So if there are no files to prune, don't attempt it. This also speeds up checkout when only a few of the checked out git repos are lfs repos. Signed-off-by: Sebastian Parborg gmail.com> Signed-off-by: Michał Górny gentoo.org> eclass/git-r3.eclass | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass index de89fdc3a223..a498bb8a5563 100644 --- a/eclass/git-r3.eclass +++ b/eclass/git-r3.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: git-r3.eclass @@ -813,13 +813,17 @@ git-r3_fetch() { if [[ ${EGIT_LFS} ]]; then # Fetch the LFS files from the current ref (if any) - local lfs_fetch_command=( git lfs fetch "${r}" ) + local lfs_fetch_command=( git lfs fetch "${r}" "${remote_ref}" ) case "${EGIT_LFS_CLONE_TYPE}" in shallow) - lfs_fetch_command+=( - --prune - ) + if [[ -d ${GIT_DIR}/lfs/objects ]] && ! rmdir "${GIT_DIR}"/lfs/objects 2> /dev/null; then + # Only prune if the lfs directory is not empty. + # The prune command can take a very long time to resolve even if there are no lfs objects. + lfs_fetch_command+=( + --prune + ) + fi ;; single) ;;