1 |
For files returned by git diff-index, call git update-index in order |
2 |
to ensure that the index reflects the state on disk. This will prevent |
3 |
incorrect assumptions in cases where the index is missing or stale for |
4 |
some reason. Since repoman uses this information to decide when to |
5 |
update copyright header dates, this can prevent spurious copyright |
6 |
header updates. |
7 |
|
8 |
Signed-off-by: Zac Medico <zmedico@g.o> |
9 |
Bug: https://bugs.gentoo.org/712106 |
10 |
--- |
11 |
repoman/lib/repoman/modules/vcs/git/changes.py | 15 ++++++++++++--- |
12 |
1 file changed, 12 insertions(+), 3 deletions(-) |
13 |
|
14 |
diff --git a/repoman/lib/repoman/modules/vcs/git/changes.py b/repoman/lib/repoman/modules/vcs/git/changes.py |
15 |
index 7e9ac1eb5..ebf770d53 100644 |
16 |
--- a/repoman/lib/repoman/modules/vcs/git/changes.py |
17 |
+++ b/repoman/lib/repoman/modules/vcs/git/changes.py |
18 |
@@ -29,8 +29,14 @@ class Changes(ChangesBase): |
19 |
''' |
20 |
super(Changes, self).__init__(options, repo_settings) |
21 |
|
22 |
- def _scan(self): |
23 |
- '''VCS type scan function, looks for all detectable changes''' |
24 |
+ def _scan(self, _reindex=True): |
25 |
+ ''' |
26 |
+ VCS type scan function, looks for all detectable changes |
27 |
+ |
28 |
+ @param _reindex: ensure that the git index reflects the state on |
29 |
+ disk for files returned by git diff-index |
30 |
+ @type _reindex: bool |
31 |
+ ''' |
32 |
with repoman_popen( |
33 |
"git diff-index --name-only " |
34 |
"--relative --diff-filter=M HEAD") as f: |
35 |
@@ -51,6 +57,9 @@ class Changes(ChangesBase): |
36 |
removed = f.readlines() |
37 |
self.removed = ["./" + elem[:-1] for elem in removed] |
38 |
del removed |
39 |
+ if _reindex and (self.changed or self.new or self.removed): |
40 |
+ self.update_index([], self.changed + self.new + self.removed) |
41 |
+ self._scan(_reindex=False) |
42 |
|
43 |
@property |
44 |
def unadded(self): |
45 |
@@ -91,7 +100,7 @@ class Changes(ChangesBase): |
46 |
# of the working tree. |
47 |
myfiles = mymanifests + myupdates |
48 |
myfiles.sort() |
49 |
- update_index_cmd = ["git", "update-index"] |
50 |
+ update_index_cmd = ["git", "update-index", "--add", "--remove"] |
51 |
update_index_cmd.extend(f.lstrip("./") for f in myfiles) |
52 |
if self.options.pretend: |
53 |
print("(%s)" % (" ".join(update_index_cmd),)) |
54 |
-- |
55 |
2.24.1 |