public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/2] git-r3.eclass: Fix fetching git lfs files at certain refs. Only prune when needed.
@ 2024-03-28 21:29 Sebastian Parborg
  2024-03-28 21:36 ` [gentoo-dev] [PATCH 2/2] git-r3.eclass: Add the ability to checkout ignored submodules Sebastian Parborg
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Parborg @ 2024-03-28 21:29 UTC (permalink / raw)
  To: gentoo-dev

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-dev] [PATCH 2/2] git-r3.eclass: Add the ability to checkout ignored submodules.
  2024-03-28 21:29 [gentoo-dev] [PATCH 1/2] git-r3.eclass: Fix fetching git lfs files at certain refs. Only prune when needed Sebastian Parborg
@ 2024-03-28 21:36 ` Sebastian Parborg
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Parborg @ 2024-03-28 21:36 UTC (permalink / raw)
  To: gentoo-dev

If the submodules is specified in EGIT_SUBMODULES then it will ignore
the "none" check.

Signed-off-by: Sebastian Parborg <darkdefende@gmail.com>
---
 eclass/git-r3.eclass | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
index 17b750001767..8d95d9a2b5af 100644
--- a/eclass/git-r3.eclass
+++ b/eclass/git-r3.eclass
@@ -429,6 +429,7 @@ _git-r3_set_submodules() {
 
 		l=${l#submodule.}
 		local subname=${l%%.url=*}
+		local is_manually_specified=
 
 		# filter out on EGIT_SUBMODULES
 		if declare -p EGIT_SUBMODULES &>/dev/null; then
@@ -449,13 +450,14 @@ _git-r3_set_submodules() {
 				continue
 			else
 				einfo "Using submodule ${parent_path}${subname}"
+				is_manually_specified=1
 			fi
 		fi
 
 		# skip modules that have 'update = none', bug #487262.
 		local upd=$(echo "${data}" | git config -f /dev/fd/0 \
 			submodule."${subname}".update)
-		[[ ${upd} == none ]] && continue
+		[[ ${upd} == none && ! ${is_manually_specified} ]] && continue
 
 		# https://github.com/git/git/blob/master/refs.c#L31
 		# we are more restrictive than git itself but that should not
-- 
2.43.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-28 21:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-28 21:29 [gentoo-dev] [PATCH 1/2] git-r3.eclass: Fix fetching git lfs files at certain refs. Only prune when needed Sebastian Parborg
2024-03-28 21:36 ` [gentoo-dev] [PATCH 2/2] git-r3.eclass: Add the ability to checkout ignored submodules Sebastian Parborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox