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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id DE10D138350 for ; Sun, 15 Mar 2020 01:47:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AD6FBE0BA0; Sun, 15 Mar 2020 01:47:08 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8EF14E0BA0 for ; Sun, 15 Mar 2020 01:47:08 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 226C634F010 for ; Sun, 15 Mar 2020 01:47:07 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BFAD5168 for ; Sun, 15 Mar 2020 01:47:04 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1584236784.c93dc19cb0f8d5769ee13b7f2ccaeaf661013f30.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: repoman/lib/repoman/modules/vcs/git/ X-VCS-Repository: proj/portage X-VCS-Files: repoman/lib/repoman/modules/vcs/git/changes.py X-VCS-Directories: repoman/lib/repoman/modules/vcs/git/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: c93dc19cb0f8d5769ee13b7f2ccaeaf661013f30 X-VCS-Branch: master Date: Sun, 15 Mar 2020 01:47:04 +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: ccd69497-613d-4dae-8bdc-1125c9984267 X-Archives-Hash: a61f5e3adef484f50492a8efaf7e968e commit: c93dc19cb0f8d5769ee13b7f2ccaeaf661013f30 Author: Zac Medico gentoo org> AuthorDate: Sun Mar 15 01:44:27 2020 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Mar 15 01:46:24 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=c93dc19c repoman.modules.vcs.git.changes: reindex (bug 712106) For files returned by git diff-index, call git update-index in order to ensure that the index reflects the state on disk. This will prevent incorrect assumptions in cases where the index is missing or stale for some reason. Since repoman uses this information to decide when to update copyright header dates, this can prevent spurious copyright header updates. Signed-off-by: Zac Medico gentoo.org> Bug: https://bugs.gentoo.org/712106 repoman/lib/repoman/modules/vcs/git/changes.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/repoman/lib/repoman/modules/vcs/git/changes.py b/repoman/lib/repoman/modules/vcs/git/changes.py index 7e9ac1eb5..550028434 100644 --- a/repoman/lib/repoman/modules/vcs/git/changes.py +++ b/repoman/lib/repoman/modules/vcs/git/changes.py @@ -29,8 +29,16 @@ class Changes(ChangesBase): ''' super(Changes, self).__init__(options, repo_settings) - def _scan(self): - '''VCS type scan function, looks for all detectable changes''' + def _scan(self, _reindex=True): + ''' + VCS type scan function, looks for all detectable changes + + @param _reindex: ensure that the git index reflects the state on + disk for files returned by git diff-index (this parameter is + used in recursive calls and it's not intended to be used for + any other reason) + @type _reindex: bool + ''' with repoman_popen( "git diff-index --name-only " "--relative --diff-filter=M HEAD") as f: @@ -51,6 +59,9 @@ class Changes(ChangesBase): removed = f.readlines() self.removed = ["./" + elem[:-1] for elem in removed] del removed + if _reindex and (self.changed or self.new or self.removed): + self.update_index([], self.changed + self.new + self.removed) + self._scan(_reindex=False) @property def unadded(self): @@ -91,7 +102,7 @@ class Changes(ChangesBase): # of the working tree. myfiles = mymanifests + myupdates myfiles.sort() - update_index_cmd = ["git", "update-index"] + update_index_cmd = ["git", "update-index", "--add", "--remove"] update_index_cmd.extend(f.lstrip("./") for f in myfiles) if self.options.pretend: print("(%s)" % (" ".join(update_index_cmd),))