Changeset - ce5b7896d288
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 7 years ago 2019-03-28 21:49:07
thomas.de_schampheleire@nokia.com
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.
1 file changed with 8 insertions and 7 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/git/changeset.py
Show inline comments
 
@@ -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):
0 comments (0 inline, 0 general)