From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 1B300158020 for ; Wed, 21 Dec 2022 01:28:15 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 26FE6E0978; Wed, 21 Dec 2022 01:28:14 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.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 F1288E0978 for ; Wed, 21 Dec 2022 01:28:13 +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 3064C341698 for ; Wed, 21 Dec 2022 01:28:13 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 6DF557E7 for ; Wed, 21 Dec 2022 01:28:10 +0000 (UTC) From: "Sam James" 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" Message-ID: <1671586083.cc20629da347393e6987fa58231e4b773ca0a5e7.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: cc20629da347393e6987fa58231e4b773ca0a5e7 X-VCS-Branch: master Date: Wed, 21 Dec 2022 01:28:10 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 54a80d08-b569-4237-8190-d052ceef8199 X-Archives-Hash: 1f30c8a90353234a6d7b5295e1810463 commit: cc20629da347393e6987fa58231e4b773ca0a5e7 Author: John Helmert III gentoo org> AuthorDate: Sun Nov 20 04:47:13 2022 +0000 Commit: Sam James gentoo org> CommitDate: Wed Dec 21 01:28:03 2022 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=cc20629d sync: git: add GIT_CEILING_DIRECTORIES for update operations Bug: https://bugs.gentoo.org/887025 Signed-off-by: John Helmert III gentoo.org> Closes: https://github.com/gentoo/portage/pull/939 Signed-off-by: Sam James gentoo.org> lib/portage/sync/modules/git/git.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py index e768e6861..7af665e5f 100644 --- a/lib/portage/sync/modules/git/git.py +++ b/lib/portage/sync/modules/git/git.py @@ -116,6 +116,22 @@ class GitSync(NewBase): return (os.EX_OK, True) + def _gen_ceiling_string(self, path): + """ + Iteratively generate a colon delimited string of all of the + given path's parents, for use with GIT_CEILING_DIRECTORIES + """ + path = self.repo.location + directories = [] + + while True: + if path == "/": + break + path = os.path.dirname(path) + directories.append(path) + + return ":".join(directories) + def update(self): """Update existing git repository, and ignore the syncuri. We are going to trust the user and assume that the user is in the branch @@ -126,6 +142,13 @@ class GitSync(NewBase): return (1, False) git_cmd_opts = "" quiet = self.settings.get("PORTAGE_QUIET") == "1" + + # We don't want to operate with a .git outside of the given + # repo in any circumstances. + self.spawn_kwargs["env"].update( + {"GIT_CEILING_DIRECTORIES": self._gen_ceiling_string(self.repo.location)} + ) + if self.repo.module_specific_options.get("sync-git-env"): shlexed_env = shlex_split(self.repo.module_specific_options["sync-git-env"]) env = {