commit: ac405c994a0cce67e11c1bc7fb37fc02bba627ae Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Sat Dec 17 05:19:32 2022 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Wed Dec 21 01:28:03 2022 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ac405c99
sync: git: allow truncating history if repository is marked volatile See 54a08c9f71dc37851fdb0364576581ca19df6580 for an explanation of the context here. If the repository is marked as volatile, it's assumed that Portage has complete control of it, and for Portage's purposes, there's no use in having extended history (in fact, if anything, it's deterimental, as it makes a sync more likely to fail due to the large disk space requirements over time). Bug: https://bugs.gentoo.org/824782 Bug: https://bugs.gentoo.org/887025 Signed-off-by: Sam James <sam <AT> gentoo.org> lib/portage/sync/modules/git/git.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py index f16af0622..8602fecba 100644 --- a/lib/portage/sync/modules/git/git.py +++ b/lib/portage/sync/modules/git/git.py @@ -155,19 +155,24 @@ class GitSync(NewBase): if self.repo.sync_depth is not None: sync_depth = self.repo.sync_depth else: - # If sync-depth is not explicitly set by the user, - # then check if the target repository is already a - # shallow one. And do not perform a shallow update if - # the target repository is not shallow. - is_shallow_cmd = ["git", "rev-parse", "--is-shallow-repository"] - is_shallow_res = portage._unicode_decode( - subprocess.check_output( - is_shallow_cmd, - cwd=portage._unicode_encode(self.repo.location), + if self.repo.volatile: + # If sync-depth is not explicitly set by the user, + # then check if the target repository is already a + # shallow one. And do not perform a shallow update if + # the target repository is not shallow. + is_shallow_cmd = ["git", "rev-parse", "--is-shallow-repository"] + is_shallow_res = portage._unicode_decode( + subprocess.check_output( + is_shallow_cmd, + cwd=portage._unicode_encode(self.repo.location), + ) ) - ) - if is_shallow_res == "false": - sync_depth = 0 + if is_shallow_res == "false": + sync_depth = 0 + else: + # If the repository is marked as non-volatile, we assume + # it's fine to Portage to do what it wishes to it. + sync_depth = 1 shallow = False if sync_depth > 0:
