diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2024-03-25 16:08:41 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2024-04-01 11:36:28 +0200 |
commit | e686f42afb87ef04362e6c24968d5050e6bb5c91 (patch) | |
tree | af85dda57d3ff568d9a2c6eaa23bc898441c3ca2 /eclass/git-r3.eclass | |
parent | dev-python/pytest-xprocess: Bump to 1.0.1 (diff) | |
download | gentoo-e686f42afb87ef04362e6c24968d5050e6bb5c91.tar.gz gentoo-e686f42afb87ef04362e6c24968d5050e6bb5c91.tar.bz2 gentoo-e686f42afb87ef04362e6c24968d5050e6bb5c91.zip |
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 <darkdefende@gmail.com>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/git-r3.eclass')
-rw-r--r-- | eclass/git-r3.eclass | 14 |
1 files 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) ;; |