* [gentoo-commits] proj/portage:master commit in: repoman/lib/repoman/modules/vcs/git/
@ 2020-03-15 1:47 Zac Medico
0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2020-03-15 1:47 UTC (permalink / raw
To: gentoo-commits
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),))
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/portage:master commit in: repoman/lib/repoman/modules/vcs/git/
@ 2020-03-25 19:57 Zac Medico
0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2020-03-25 19:57 UTC (permalink / raw
To: gentoo-commits
commit: f11cabb3c9fe7d09d86f40cc716f14e9b0aed765
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 25 19:53:45 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Mar 25 19:54:48 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f11cabb3
repoman.modules.vcs.git.changes: reindex only for commit mode (bug 712106)
Automatically reindex for commit mode, but not for other modes
were the user might not want changes to be staged in the index.
Bug: https://bugs.gentoo.org/712106
Suggested-by: Jeroen Roovers <jer <AT> gentoo.org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
repoman/lib/repoman/modules/vcs/git/changes.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/repoman/lib/repoman/modules/vcs/git/changes.py b/repoman/lib/repoman/modules/vcs/git/changes.py
index 550028434..9819831b5 100644
--- a/repoman/lib/repoman/modules/vcs/git/changes.py
+++ b/repoman/lib/repoman/modules/vcs/git/changes.py
@@ -29,7 +29,7 @@ class Changes(ChangesBase):
'''
super(Changes, self).__init__(options, repo_settings)
- def _scan(self, _reindex=True):
+ def _scan(self, _reindex=None):
'''
VCS type scan function, looks for all detectable changes
@@ -39,6 +39,11 @@ class Changes(ChangesBase):
any other reason)
@type _reindex: bool
'''
+ # Automatically reindex for commit mode, but not for other modes
+ # were the user might not want changes to be staged in the index.
+ if _reindex is None and self.options.mode == 'commit':
+ _reindex = True
+
with repoman_popen(
"git diff-index --name-only "
"--relative --diff-filter=M HEAD") as f:
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-03-25 19:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-15 1:47 [gentoo-commits] proj/portage:master commit in: repoman/lib/repoman/modules/vcs/git/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2020-03-25 19:57 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox