summaryrefslogtreecommitdiff
path: root/lib/git
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git')
-rw-r--r--lib/git/objects/base.py5
-rw-r--r--lib/git/repo/base.py13
2 files changed, 10 insertions, 8 deletions
diff --git a/lib/git/objects/base.py b/lib/git/objects/base.py
index 82c2589c..b8cec47f 100644
--- a/lib/git/objects/base.py
+++ b/lib/git/objects/base.py
@@ -114,7 +114,10 @@ class Object(LazyMixin):
class IndexObject(Object):
"""Base for all objects that can be part of the index file , namely Tree, Blob and
SubModule objects"""
- __slots__ = ("path", "mode")
+ __slots__ = ("path", "mode")
+
+ # for compatability with iterable lists
+ _id_attribute_ = 'path'
def __init__(self, repo, binsha, mode=None, path=None):
"""Initialize a newly instanced IndexObject
diff --git a/lib/git/repo/base.py b/lib/git/repo/base.py
index 3a395af0..0355b062 100644
--- a/lib/git/repo/base.py
+++ b/lib/git/repo/base.py
@@ -225,7 +225,7 @@ class Repo(object):
@property
def submodules(self):
""":return: git.IterableList(Submodule, ...) of direct submodules"""
- return self.list_submodules(recursive=False)
+ return Submodule.list_items(self)
def submodule(self, name):
""":return: Submodule with the given name
@@ -236,12 +236,11 @@ class Repo(object):
raise ValueError("Didn't find submodule named %r" % name)
# END exception handling
- def list_submodules(self, recursive=False):
- """A list if Submodule objects available in this repository
- :param recursive: If True, submodules of submodules (and so forth) will be
- returned as well as part of a depth-first traversal
- :return: ``git.IterableList(Submodule, ...)"""
- return RootModule(self).list_traverse(ignore_self=1, depth = recursive and -1 or 1)
+ def iter_submodules(self, *args, **kwargs):
+ """An iterator yielding Submodule instances, see Traversable interface
+ for a description of args and kwargs
+ :return: Iterator"""
+ return RootModule(self).traverse(*args, **kwargs)
@property
def tags(self):