diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-11-04 12:46:37 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-11-04 12:46:37 +0100 |
commit | c4cde8df886112ee32b0a09fcac90c28c85ded7f (patch) | |
tree | 3331b64af12952d4fb961e0db712192d990c548d /lib/git/objects/tree.py | |
parent | f9bbdc87a7263f479344fcf67c4b9fd6005bb6cd (diff) | |
download | gitpython-c4cde8df886112ee32b0a09fcac90c28c85ded7f.tar.gz |
IndexObject: assured that .path fields are relative to the repository ( previously it would just be a name )
added abspath property and name property to provide easy access to most common paths of an index object
Diffstat (limited to 'lib/git/objects/tree.py')
-rw-r--r-- | lib/git/objects/tree.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/git/objects/tree.py b/lib/git/objects/tree.py index fb292677..bcb805af 100644 --- a/lib/git/objects/tree.py +++ b/lib/git/objects/tree.py @@ -110,6 +110,7 @@ class Tree(base.IndexObject, diff.Diffable): i += 1 # END while not reached NULL name = data[ns:i] + path = os.path.join(self.path, name) # byte is NULL, get next 20 i += 1 @@ -119,9 +120,9 @@ class Tree(base.IndexObject, diff.Diffable): mode |= type_id<<12 hexsha = sha_to_hex(sha) if type_id == self.blob_id or type_id == self.symlink_id: - yield blob.Blob(self.repo, hexsha, mode, name) + yield blob.Blob(self.repo, hexsha, mode, path) elif type_id == self.tree_id: - yield Tree(self.repo, hexsha, mode, name) + yield Tree(self.repo, hexsha, mode, path) elif type_id == self.commit_id: # todo yield None @@ -157,8 +158,6 @@ class Tree(base.IndexObject, diff.Diffable): def _iter_recursive(cls, repo, tree, cur_depth, max_depth, predicate, prune ): for obj in tree: - # adjust path to be complete - obj.path = os.path.join(tree.path, obj.path) if predicate(obj): yield obj if obj.type == "tree" and ( max_depth < 0 or cur_depth+1 <= max_depth ) and not prune(obj): @@ -173,7 +172,8 @@ class Tree(base.IndexObject, diff.Diffable): Returns Iterator to traverse the tree recursively up to the given level. - The iterator returns Blob and Tree objects + The iterator returns Blob and Tree objects with paths relative to their + repository. ``max_depth`` |