# HG changeset patch # User Thomas De Schampheleire # Date 2019-03-28 21:49:07 # Node ID ce5b7896d288cd63269ec34baa99defbdc98f863 # Parent bd6713ab3fc052c692a10c897b4a8cc7a4667765 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. diff --git a/kallithea/lib/vcs/backends/git/changeset.py b/kallithea/lib/vcs/backends/git/changeset.py --- a/kallithea/lib/vcs/backends/git/changeset.py +++ b/kallithea/lib/vcs/backends/git/changeset.py @@ -410,18 +410,19 @@ class GitChangeset(BaseChangeset): 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):