Mailing List Archive

[PATCH 1/2] git-r3.eclass: Fix fetching git lfs files at certain refs. Only prune when needed.
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