@@ -80,11 +80,11 @@ def name(self):
8080
8181 @property
8282 def abspath (self ):
83- return join_path_native (self .odb .git_dir , self .path )
83+ return join_path_native (self .odb .root_path () , self .path )
8484
8585 @classmethod
8686 def _get_packed_refs_path (cls , odb ):
87- return join (odb .git_dir , 'packed-refs' )
87+ return join (odb .root_path () , 'packed-refs' )
8888
8989 @classmethod
9090 def _iter_packed_refs (cls , odb ):
@@ -137,7 +137,7 @@ def _get_ref_info(cls, odb, ref_path):
137137 point to, or None"""
138138 tokens = None
139139 try :
140- fp = open (join (odb .git_dir , ref_path ), 'r' )
140+ fp = open (join (odb .root_path () , ref_path ), 'r' )
141141 value = fp .read ().rstrip ()
142142 fp .close ()
143143 tokens = value .split (" " )
@@ -159,7 +159,7 @@ def _get_ref_info(cls, odb, ref_path):
159159 return (None , tokens [1 ])
160160
161161 # its a commit
162- if re_hexsha_only .match (tokens [0 ]):
162+ if cls . re_hexsha_only .match (tokens [0 ]):
163163 return (tokens [0 ], None )
164164
165165 raise ValueError ("Failed to parse reference information from %r" % ref_path )
@@ -177,7 +177,7 @@ def _get_object(self):
177177 The object our ref currently refers to."""
178178 # have to be dynamic here as we may be a tag which can point to anything
179179 # Our path will be resolved to the hexsha which will be used accordingly
180- return self .ObjectCls .new_from_sha (self ._get_object_sha ())
180+ return self .ObjectCls .new_from_sha (self .odb , self . _get_object_sha ())
181181
182182 def set_object (self , object_id , logmsg = None ):
183183 """Set the object we point to, possibly dereference our symbolic reference first.
@@ -341,7 +341,7 @@ def is_valid(self):
341341 a valid object or reference."""
342342 try :
343343 self .object
344- except (OSError , ValueError ):
344+ except (OSError , ValueError , BadObject ):
345345 return False
346346 else :
347347 return True
@@ -414,7 +414,7 @@ def delete(cls, odb, path):
414414 or just "myreference", hence 'refs/' is implied.
415415 Alternatively the symbolic reference to be deleted"""
416416 full_ref_path = cls .to_full_path (path )
417- abs_path = join (odb .git_dir , full_ref_path )
417+ abs_path = join (odb .root_path () , full_ref_path )
418418 if exists (abs_path ):
419419 os .remove (abs_path )
420420 else :
@@ -467,7 +467,7 @@ def _create(cls, odb, path, resolve, reference, force, logmsg=None):
467467 corresponding object and a detached symbolic reference will be created
468468 instead"""
469469 full_ref_path = cls .to_full_path (path )
470- abs_ref_path = join (odb .git_dir , full_ref_path )
470+ abs_ref_path = join (odb .root_path () , full_ref_path )
471471
472472 # figure out target data
473473 target = reference
@@ -539,8 +539,8 @@ def rename(self, new_path, force=False):
539539 if self .path == new_path :
540540 return self
541541
542- new_abs_path = join (self .odb .git_dir , new_path )
543- cur_abs_path = join (self .odb .git_dir , self .path )
542+ new_abs_path = join (self .odb .root_path () , new_path )
543+ cur_abs_path = join (self .odb .root_path () , self .path )
544544 if isfile (new_abs_path ):
545545 if not force :
546546 # if they point to the same file, its not an error
@@ -570,7 +570,7 @@ def _iter_items(cls, odb, common_path = None):
570570
571571 # walk loose refs
572572 # Currently we do not follow links
573- for root , dirs , files in os .walk (join_path_native (odb .git_dir , common_path )):
573+ for root , dirs , files in os .walk (join_path_native (odb .root_path () , common_path )):
574574 if 'refs/' not in root : # skip non-refs subfolders
575575 refs_id = [ i for i ,d in enumerate (dirs ) if d == 'refs' ]
576576 if refs_id :
@@ -579,7 +579,7 @@ def _iter_items(cls, odb, common_path = None):
579579
580580 for f in files :
581581 abs_path = to_native_path_linux (join_path (root , f ))
582- rela_paths .add (abs_path .replace (to_native_path_linux (odb .git_dir ) + '/' , "" ))
582+ rela_paths .add (abs_path .replace (to_native_path_linux (odb .root_path () ) + '/' , "" ))
583583 # END for each file in root directory
584584 # END for each directory to walk
585585
@@ -611,8 +611,8 @@ def iter_items(cls, odb, common_path = None):
611611 refs suitable for the actual class are returned.
612612
613613 :return:
614- git.SymbolicReference[], each of them is guaranteed to be a symbolic
615- ref which is not detached.
614+ git.SymbolicReference[], each of them is guaranteed to be a *only* a symbolic
615+ ref, or a derived class which is not detached
616616
617617 List is lexigraphically sorted
618618 The returned objects represent actual subclasses, such as Head or TagReference"""
0 commit comments