2121)
2222from git .compat import (
2323string_types ,
24+ defenc
2425)
2526
2627from .log import RefLog
@@ -429,6 +430,7 @@ def delete(cls, repo, path):
429430# in the line
430431# If we deleted the last line and this one is a tag-reference object,
431432# we drop it as well
433+ line = line .decode (defenc )
432434if (line .startswith ('#' )or full_ref_path not in line )and \
433435 (not dropped_last_line or dropped_last_line and not line .startswith ('^' )):
434436new_lines .append (line )
@@ -446,7 +448,7 @@ def delete(cls, repo, path):
446448if made_change :
447449# write-binary is required, otherwise windows will
448450# open the file in text mode and change LF to CRLF !
449- open (pack_file_path ,'wb' ).writelines (new_lines )
451+ open (pack_file_path ,'wb' ).writelines (l . encode ( defenc ) for l in new_lines )
450452# END write out file
451453# END open exception handling
452454# END handle deletion
@@ -478,7 +480,7 @@ def _create(cls, repo, path, resolve, reference, force, logmsg=None):
478480target_data = target .path
479481if not resolve :
480482target_data = "ref: " + target_data
481- existing_data = open (abs_ref_path ,'rb' ).read ().strip ()
483+ existing_data = open (abs_ref_path ,'rb' ).read ().decode ( defenc ). strip ()
482484if existing_data != target_data :
483485raise OSError ("Reference at %r does already exist, pointing to %r, requested was %r" %
484486 (full_ref_path ,existing_data ,target_data ))