diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-07-06 00:35:30 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-07-06 00:35:30 +0200 |
commit | f963881e53a9f0a2746a11cb9cdfa82eb1f90d8c (patch) | |
tree | ea69501e471b2bc724b641cb360f1b15c095c9d6 /lib/git/refs.py | |
parent | a4287f65878000b42d11704692f9ea3734014b4c (diff) | |
download | gitpython-f963881e53a9f0a2746a11cb9cdfa82eb1f90d8c.tar.gz |
Initial version of the rev-parse routine, which doesn't work too bad, but its still rather slow and many tests are not yet implemented
Diffstat (limited to 'lib/git/refs.py')
-rw-r--r-- | lib/git/refs.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/git/refs.py b/lib/git/refs.py index 343a0afb..a466e419 100644 --- a/lib/git/refs.py +++ b/lib/git/refs.py @@ -68,7 +68,7 @@ class SymbolicReference(object): :return: In case of symbolic references, the shortest assumable name is the path itself.""" - return self.path + return self.path def _abs_path(self): return join_path_native(self.repo.git_dir, self.path) @@ -109,6 +109,19 @@ class SymbolicReference(object): # I believe files are closing themselves on destruction, so it is # alright. + @classmethod + def dereference_recursive(cls, repo, ref_path): + """ + :return: hexsha stored in the reference at the given ref_path, recursively dereferencing all + intermediate references as required + :param repo: the repository containing the reference at ref_path""" + while True: + ref = cls(repo, ref_path) + hexsha, ref_path = ref._get_ref_info() + if hexsha is not None: + return hexsha + # END recursive dereferencing + def _get_ref_info(self): """Return: (sha, target_ref_path) if available, the sha the file at rela_path points to, or None. target_ref_path is the reference we @@ -795,6 +808,10 @@ class TagReference(Reference): raise ValueError( "Tag %s points to a Blob or Tree - have never seen that before" % self ) @property + def tree(self): + return self.commit.tree + + @property def tag(self): """ :return: Tag object this tag ref points to or None in case |