@@ -42,6 +42,7 @@ class SymbolicReference(object):
4242 #{ Configuration
4343 # Object class to be used when instantiating objects
4444 ObjectCls = Object
45+ CommitCls = Commit
4546
4647 # all of the following are set by the package initializer
4748 HEADCls = None
@@ -80,11 +81,11 @@ def name(self):
8081
8182 @property
8283 def abspath (self ):
83- return join_path_native (self .odb .root_path (), self .path )
84+ return join_path_native (self .odb .git_dir (), self .path )
8485
8586 @classmethod
8687 def _get_packed_refs_path (cls , odb ):
87- return join (odb .root_path (), 'packed-refs' )
88+ return join (odb .git_dir (), 'packed-refs' )
8889
8990 @classmethod
9091 def _iter_packed_refs (cls , odb ):
@@ -137,7 +138,7 @@ def _get_ref_info(cls, odb, ref_path):
137138 point to, or None"""
138139 tokens = None
139140 try :
140- fp = open (join (odb .root_path (), ref_path ), 'r' )
141+ fp = open (join (odb .git_dir (), ref_path ), 'r' )
141142 value = fp .read ().rstrip ()
142143 fp .close ()
143144 tokens = value .split (" " )
@@ -216,7 +217,7 @@ def _get_commit(self):
216217 obj = obj .object
217218 #END dereference tag
218219
219- if obj .type != Commit .type :
220+ if obj .type != self . CommitCls .type :
220221 raise TypeError ("Symbolic Reference pointed to object %r, commit was required" % obj )
221222 #END handle type
222223 return obj
@@ -229,13 +230,13 @@ def set_commit(self, commit, logmsg = None):
229230 :return: self"""
230231 # check the type - assume the best if it is a base-string
231232 is_invalid_type = False
232- if isinstance (commit , Object ):
233- is_invalid_type = commit .type != Commit .type
233+ if isinstance (commit , self . ObjectCls ):
234+ is_invalid_type = commit .type != self . CommitCls .type
234235 elif isinstance (commit , SymbolicReference ):
235- is_invalid_type = commit .object .type != Commit .type
236+ is_invalid_type = commit .object .type != self . CommitCls .type
236237 else :
237238 try :
238- is_invalid_type = self .odb .rev_parse (commit ).type != Commit .type
239+ is_invalid_type = self .odb .rev_parse (commit ).type != self . CommitCls .type
239240 except BadObject :
240241 raise ValueError ("Invalid object: %s" % commit )
241242 #END handle exception
@@ -286,7 +287,7 @@ def set_reference(self, ref, logmsg = None):
286287 obj = None
287288 if isinstance (ref , SymbolicReference ):
288289 write_value = "ref: %s" % ref .path
289- elif isinstance (ref , Object ):
290+ elif isinstance (ref , self . ObjectCls ):
290291 obj = ref
291292 write_value = ref .hexsha
292293 elif isinstance (ref , basestring ):
@@ -414,7 +415,7 @@ def delete(cls, odb, path):
414415 or just "myreference", hence 'refs/' is implied.
415416 Alternatively the symbolic reference to be deleted"""
416417 full_ref_path = cls .to_full_path (path )
417- abs_path = join (odb .root_path (), full_ref_path )
418+ abs_path = join (odb .git_dir (), full_ref_path )
418419 if exists (abs_path ):
419420 os .remove (abs_path )
420421 else :
@@ -467,7 +468,7 @@ def _create(cls, odb, path, resolve, reference, force, logmsg=None):
467468 corresponding object and a detached symbolic reference will be created
468469 instead"""
469470 full_ref_path = cls .to_full_path (path )
470- abs_ref_path = join (odb .root_path (), full_ref_path )
471+ abs_ref_path = join (odb .git_dir (), full_ref_path )
471472
472473 # figure out target data
473474 target = reference
@@ -539,8 +540,8 @@ def rename(self, new_path, force=False):
539540 if self .path == new_path :
540541 return self
541542
542- new_abs_path = join (self .odb .root_path (), new_path )
543- cur_abs_path = join (self .odb .root_path (), self .path )
543+ new_abs_path = join (self .odb .git_dir (), new_path )
544+ cur_abs_path = join (self .odb .git_dir (), self .path )
544545 if isfile (new_abs_path ):
545546 if not force :
546547 # if they point to the same file, its not an error
@@ -570,7 +571,7 @@ def _iter_items(cls, odb, common_path = None):
570571
571572 # walk loose refs
572573 # Currently we do not follow links
573- for root , dirs , files in os .walk (join_path_native (odb .root_path (), common_path )):
574+ for root , dirs , files in os .walk (join_path_native (odb .git_dir (), common_path )):
574575 if 'refs/' not in root : # skip non-refs subfolders
575576 refs_id = [ i for i ,d in enumerate (dirs ) if d == 'refs' ]
576577 if refs_id :
@@ -579,7 +580,7 @@ def _iter_items(cls, odb, common_path = None):
579580
580581 for f in files :
581582 abs_path = to_native_path_linux (join_path (root , f ))
582- rela_paths .add (abs_path .replace (to_native_path_linux (odb .root_path ()) + '/' , "" ))
583+ rela_paths .add (abs_path .replace (to_native_path_linux (odb .git_dir ()) + '/' , "" ))
583584 # END for each file in root directory
584585 # END for each directory to walk
585586
0 commit comments