summaryrefslogtreecommitdiff
path: root/git/refs/symbolic.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/refs/symbolic.py')
-rw-r--r--git/refs/symbolic.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py
index aec68750..1c6a3bf1 100644
--- a/git/refs/symbolic.py
+++ b/git/refs/symbolic.py
@@ -75,7 +75,7 @@ class SymbolicReference(object):
"""Returns an iterator yielding pairs of sha1/path pairs for the corresponding refs.
:note: The packed refs file will be kept open as long as we iterate"""
try:
- fp = open(cls._get_packed_refs_path(repo), 'r')
+ fp = open(cls._get_packed_refs_path(repo), 'rb')
for line in fp:
line = line.strip()
if not line:
@@ -398,7 +398,7 @@ class SymbolicReference(object):
# check packed refs
pack_file_path = cls._get_packed_refs_path(repo)
try:
- reader = open(pack_file_path)
+ reader = open(pack_file_path, 'rb')
except (OSError,IOError):
pass # it didnt exist at all
else:
@@ -425,7 +425,10 @@ class SymbolicReference(object):
# write the new lines
if made_change:
- open(pack_file_path, 'w').writelines(new_lines)
+ # write-binary is required, otherwise windows will
+ # open the file in text mode and change LF to CRLF !
+ open(pack_file_path, 'wb').writelines(new_lines)
+ # END write out file
# END open exception handling
# END handle deletion
@@ -549,7 +552,7 @@ class SymbolicReference(object):
# Currently we do not follow links
for root, dirs, files in os.walk(join_path_native(repo.git_dir, common_path)):
if 'refs/' not in root: # skip non-refs subfolders
- refs_id = [ i for i,d in enumerate(dirs) if d == 'refs' ]
+ refs_id = [ d for d in dirs if d == 'refs' ]
if refs_id:
dirs[0:] = ['refs']
# END prune non-refs folders
@@ -589,7 +592,7 @@ class SymbolicReference(object):
:return:
git.SymbolicReference[], each of them is guaranteed to be a symbolic
- ref which is not detached.
+ ref which is not detached and pointing to a valid ref
List is lexigraphically sorted
The returned objects represent actual subclasses, such as Head or TagReference"""