1 |
From: "Robin H. Johnson" <robbat2@g.o> |
2 |
|
3 |
If GIT_DIR is used, and .git is outside the root of the checkout, then |
4 |
--work-tree=... needs to be specified, otherwise any Git command that |
5 |
relies on relative directories to the root will be wrong. |
6 |
|
7 |
Signed-off-by: Robin H. Johnson <robbat2@g.o> |
8 |
--- |
9 |
bin/egencache | 31 +++++++++++++++++++++++-------- |
10 |
1 file changed, 23 insertions(+), 8 deletions(-) |
11 |
|
12 |
diff --git a/bin/egencache b/bin/egencache |
13 |
index 51d115a..2117dd9 100755 |
14 |
--- a/bin/egencache |
15 |
+++ b/bin/egencache |
16 |
@@ -758,6 +758,16 @@ class GenChangeLogs(object): |
17 |
) |
18 |
self._changelog_output = changelog_output |
19 |
self._changelog_reversed = changelog_reversed |
20 |
+ self._repo_path = self._portdb.porttrees[0] |
21 |
+ # --work-tree=... must be passed to Git if GIT_DIR is used |
22 |
+ # and GIT_DIR is not a child of the root of the checkout |
23 |
+ # eg: |
24 |
+ # GIT_DIR=$parent/work/.git/ |
25 |
+ # work-tree=$parent/staging/ |
26 |
+ # If work-tree is not passed, Git tries to use the shared |
27 |
+ # parent of the current directory and the $GIT_DIR, which can |
28 |
+ # be outside the root of the checkout. |
29 |
+ self._work_tree = '--work-tree=%s' % self._repo_path |
30 |
|
31 |
@staticmethod |
32 |
def grab(cmd): |
33 |
@@ -766,6 +776,7 @@ class GenChangeLogs(object): |
34 |
encoding=_encodings['stdio'], errors='strict') |
35 |
|
36 |
def generate_changelog(self, cp): |
37 |
+ |
38 |
try: |
39 |
output = io.open(self._changelog_output, |
40 |
mode='w', encoding=_encodings['repo.content'], |
41 |
@@ -785,7 +796,7 @@ class GenChangeLogs(object): |
42 |
''' % (cp, time.strftime('%Y')))) |
43 |
|
44 |
# now grab all the commits |
45 |
- revlist_cmd = ['git', 'rev-list'] |
46 |
+ revlist_cmd = ['git', self._work_tree, 'rev-list'] |
47 |
if self._changelog_reversed: |
48 |
revlist_cmd.append('--reverse') |
49 |
revlist_cmd.extend(['HEAD', '--', '.']) |
50 |
@@ -797,12 +808,17 @@ class GenChangeLogs(object): |
51 |
# --no-renames to avoid getting more complex records on the list |
52 |
# --format to get the timestamp, author and commit description |
53 |
# --root to make it work fine even with the initial commit |
54 |
- # --relative to get paths relative to ebuilddir |
55 |
+ # --relative=$cp to get paths relative to ebuilddir |
56 |
# -r (recursive) to get per-file changes |
57 |
# then the commit-id and path. |
58 |
|
59 |
- cinfo = self.grab(['git', 'diff-tree', '--name-status', '--no-renames', |
60 |
- '--format=%ct %cN <%cE>%n%B', '--root', '--relative', '-r', |
61 |
+ cinfo = self.grab(['git', self._work_tree, 'diff-tree', |
62 |
+ '--name-status', |
63 |
+ '--no-renames', |
64 |
+ '--format=%ct %cN <%cE>%n%B', |
65 |
+ '--root', |
66 |
+ '--relative=%s' % (cp, ), |
67 |
+ '-r', |
68 |
c, '--', '.']).rstrip('\n').split('\n') |
69 |
|
70 |
# Expected output: |
71 |
@@ -883,8 +899,7 @@ class GenChangeLogs(object): |
72 |
output.close() |
73 |
|
74 |
def run(self): |
75 |
- repo_path = self._portdb.porttrees[0] |
76 |
- os.chdir(repo_path) |
77 |
+ os.chdir(self._repo_path) |
78 |
|
79 |
if 'git' not in FindVCS(): |
80 |
writemsg_level( |
81 |
@@ -894,10 +909,10 @@ class GenChangeLogs(object): |
82 |
return |
83 |
|
84 |
for cp in self._portdb.cp_all(): |
85 |
- os.chdir(os.path.join(repo_path, cp)) |
86 |
+ os.chdir(os.path.join(self._repo_path, cp)) |
87 |
# Determine whether ChangeLog is up-to-date by comparing |
88 |
# the newest commit timestamp with the ChangeLog timestamp. |
89 |
- lmod = self.grab(['git', 'log', '--format=%ct', '-1', '.']) |
90 |
+ lmod = self.grab(['git', self._work_tree, 'log', '--format=%ct', '-1', '.']) |
91 |
if not lmod: |
92 |
# This cp has not been added to the repo. |
93 |
continue |
94 |
-- |
95 |
2.3.0 |