public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Sebastian Parborg <darkdefende@gmail.com>
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.
Date: Thu, 28 Mar 2024 22:29:12 +0100	[thread overview]
Message-ID: <ZgXhKOH-o9DUPy6F@NeoTokyo> (raw)

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 <darkdefende@gmail.com>
---
 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



             reply	other threads:[~2024-03-28 21:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28 21:29 Sebastian Parborg [this message]
2024-03-28 21:36 ` [gentoo-dev] [PATCH 2/2] git-r3.eclass: Add the ability to checkout ignored submodules Sebastian Parborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZgXhKOH-o9DUPy6F@NeoTokyo \
    --to=darkdefende@gmail.com \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox