diff options
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  | 
