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 07976158020 for ; Wed, 21 Dec 2022 01:28:14 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CD48CE0972; 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 B8832E0972 for ; 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 C289A341693 for ; Wed, 21 Dec 2022 01:28:11 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5B48E7DE 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.1696966564510e8359e3e29681dc1326c37c6e0b.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: 1696966564510e8359e3e29681dc1326c37c6e0b 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: f76ab896-2227-426a-bad1-c3856c755f1e X-Archives-Hash: 9fec798a174bbb6aeb12a4fa467ce535 commit: 1696966564510e8359e3e29681dc1326c37c6e0b Author: John Helmert III gentoo org> AuthorDate: Thu Nov 3 02:48:59 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=16969665 sync: git: `git clean` the repo before updating With a shallow clone, git may leave orphaned files if the remote moves from state X -> X-1. If on pulling again, state X is returned, git will then abort to avoid clobbering untracked files. Bug: https://bugs.gentoo.org/887025 Signed-off-by: John Helmert III gentoo.org> Signed-off-by: Sam James gentoo.org> lib/portage/sync/modules/git/git.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py index 8602fecba..e768e6861 100644 --- a/lib/portage/sync/modules/git/git.py +++ b/lib/portage/sync/modules/git/git.py @@ -250,6 +250,24 @@ class GitSync(NewBase): if not self.verify_head(revision="refs/remotes/%s" % remote_branch): return (1, False) + # Clean up the repo before trying to sync to upstream's + clean_cmd = [self.bin_command, "clean", "--force", "-d", "-x"] + + if quiet: + clean_cmd.append("--quiet") + + portage.process.spawn( + clean_cmd, + cwd=portage._unicode_encode(self.repo.location), + **self.spawn_kwargs, + ) + + if exitcode != os.EX_OK: + msg = "!!! git clean error in %s" % self.repo.location + self.logger(self.xterm_titles, msg) + writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1) + return (exitcode, False) + # `git diff --quiet` returns 0 on a clean tree and 1 otherwise is_clean = ( portage.process.spawn(