From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1469820-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id B8EA6158020
	for <garchives@archives.gentoo.org>; Wed, 21 Dec 2022 01:28:13 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id A8704E0943;
	Wed, 21 Dec 2022 01:28:12 +0000 (UTC)
Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 79610E0943
	for <gentoo-commits@lists.gentoo.org>; Wed, 21 Dec 2022 01:28:12 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id A761834168C
	for <gentoo-commits@lists.gentoo.org>; Wed, 21 Dec 2022 01:28:11 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 48C407DC
	for <gentoo-commits@lists.gentoo.org>; Wed, 21 Dec 2022 01:28:10 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1671586083.ac405c994a0cce67e11c1bc7fb37fc02bba627ae.sam@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
X-VCS-Repository: proj/portage
X-VCS-Files: lib/portage/sync/modules/git/git.py
X-VCS-Directories: lib/portage/sync/modules/git/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: ac405c994a0cce67e11c1bc7fb37fc02bba627ae
X-VCS-Branch: master
Date: Wed, 21 Dec 2022 01:28:10 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: a9f49dd2-ccc2-4c51-b218-f7c8ae1e1cfa
X-Archives-Hash: 7f44630f9c240fd938c7903736acb657

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: