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 890A6158041 for ; Thu, 28 Mar 2024 21:29:21 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 012B0E29E6; Thu, 28 Mar 2024 21:29:15 +0000 (UTC) Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (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 BA2D9E29E3 for ; Thu, 28 Mar 2024 21:29:15 +0000 (UTC) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-56bdf81706aso1810051a12.2 for ; Thu, 28 Mar 2024 14:29:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711661354; x=1712266154; darn=lists.gentoo.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=uZaOxPAOAbVBPclq5PTaSPjq7IAts9XO4fmui0GIFWQ=; b=Ooew6S89qlqw2cSYXJSKnTIyFkTx466o7ceKXfW2EooGMzVrrFQ8B0XjiojjbwMpTR JUH8VKucTF1KhSLACRPjHAbheb8OoWZ/rtpV7WJKTwg0tSAk1oJL6w4KRIDY/1M88ksh l6fj/lFpyATKCbbZVY4/Q8vpLo6WSMWNmS0xNppyXIgff6FCWojVcqc1YrDGPB56Vx2S DgqFUgaNUJZUH1wwxoq29O5ggDgiReNbGmQXvPciUnNDxS3cGkGrQ71aCdFmFrfXwc6r 8zbDT1iTGO2w0vUKmEM2RiE4+GitqB/y3qR35pr1PuhOAnelgVlHxhCGDl7demQpdbqm k0Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711661354; x=1712266154; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uZaOxPAOAbVBPclq5PTaSPjq7IAts9XO4fmui0GIFWQ=; b=QUGYa5lnUOevbggBHV8VVGQP50r6UC1EccL8Pph2M/j1Z+/8L9c13MLSZ9A8R4LV1F rCSgq8U9qKcCrTxBhurRJrY8U9NnPWlJMxUjedNABG3fFB5M45BUyY+hkQRXR4jYYH6H J45pakKXfog0aYLnhw6sKrLGo6WH9wQnmQ2Dl2D4rsV6tAcfS7xbfPb+9OHwmwnSkScf GUxMtCDkyWEpkuDlqFtHirJ6hHbC3oxJjjAzKQS/ocdYzO2VRZTKLko0TU8ylHOTPeiD wzrj+Zqp7rVEEXQCaal2HDks7AzU6Cnr660GojLuKvKR/r2kExImiQ7FEfmTOawmjbD0 5bWg== X-Gm-Message-State: AOJu0YwCJKpO5NVoilscKrOHPx/w8SuEHiYqt0VvoHJ7McvOts3Oq1gw H3La6F3sjRLV4u0Cl1FfjyxEhno0mLtuTl7oLAnH1qnLp/1xDZJoJOkIAwU7 X-Google-Smtp-Source: AGHT+IEROgBmIAmLsslGfMH816jbxgtP1B1HUxc1we7FYaOKBIb98gsN8JNKQmSwhkpd0y0JkpW7wQ== X-Received: by 2002:a50:d79a:0:b0:56b:d153:8fe0 with SMTP id w26-20020a50d79a000000b0056bd1538fe0mr292940edi.2.1711661353694; Thu, 28 Mar 2024 14:29:13 -0700 (PDT) Received: from NeoTokyo (2001-1c08-0283-7d00-f171-43b0-54df-4736.cable.dynamic.v6.ziggo.nl. [2001:1c08:283:7d00:f171:43b0:54df:4736]) by smtp.gmail.com with ESMTPSA id f25-20020a056402161900b0056bc0c44f02sm1230374edv.96.2024.03.28.14.29.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 14:29:13 -0700 (PDT) Date: Thu, 28 Mar 2024 22:29:12 +0100 From: Sebastian Parborg To: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] [PATCH 1/2] git-r3.eclass: Fix fetching git lfs files at certain refs. Only prune when needed. Message-ID: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Archives-Salt: 7024ac09-2819-4500-aa6e-4355dfa7ab59 X-Archives-Hash: 0e36a51cd03cfdf119b0cce56d723f35 If a lfs file 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 --- eclass/git-r3.eclass | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass index de89fdc3a223..17b750001767 100644 --- a/eclass/git-r3.eclass +++ b/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) ;; -- 2.43.2