commit: c93dc19cb0f8d5769ee13b7f2ccaeaf661013f30 Author: Zac Medico <zmedico <AT> gentoo <DOT> org> AuthorDate: Sun Mar 15 01:44:27 2020 +0000 Commit: Zac Medico <zmedico <AT> gentoo <DOT> 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 <zmedico <AT> 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),))
