changeset 7619:ce5b7896d288

git: fix handling of submodules that are not in the repo root (Issue #337) GitChangeset.get_nodes() did not handle submodules correctly if they were not located in the repository root. The file .gitmodules was searched in the 'tree' object being handled, which would be a subdirectory, while the real .gitmodules file is in the root tree of the repository. Instead of using 'name', the 'path' should be used. This problem was noticed during indexing of such repositories.
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Thu, 28 Mar 2019 21:49:07 +0100
parents bd6713ab3fc0
children 42383fe2533a
files kallithea/lib/vcs/backends/git/changeset.py
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/vcs/backends/git/changeset.py	Tue Mar 26 22:20:29 2019 +0100
+++ b/kallithea/lib/vcs/backends/git/changeset.py	Thu Mar 28 21:49:07 2019 +0100
@@ -410,18 +410,19 @@
         filenodes = []
         als = self.repository.alias
         for name, stat, id in tree.iteritems():
+            if path != '':
+                obj_path = '/'.join((path, name))
+            else:
+                obj_path = name
             if objects.S_ISGITLINK(stat):
-                cf = ConfigFile.from_file(BytesIO(self.repository._repo.get_object(tree['.gitmodules'][1]).data))
-                url = cf.get(('submodule', name), 'url')
-                dirnodes.append(SubModuleNode(name, url=url, changeset=id,
+                root_tree = self.repository._repo[self._tree_id]
+                cf = ConfigFile.from_file(BytesIO(self.repository._repo.get_object(root_tree['.gitmodules'][1]).data))
+                url = cf.get(('submodule', obj_path), 'url')
+                dirnodes.append(SubModuleNode(obj_path, url=url, changeset=id,
                                               alias=als))
                 continue
 
             obj = self.repository._repo.get_object(id)
-            if path != '':
-                obj_path = '/'.join((path, name))
-            else:
-                obj_path = name
             if obj_path not in self._stat_modes:
                 self._stat_modes[obj_path] = stat
             if isinstance(obj, objects.Tree):