diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2011-06-08 01:27:28 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2011-06-08 01:27:28 +0200 |
commit | fcc166d3a6e235933e823e82e1fcf6160a32a5d3 (patch) | |
tree | 8dc9adad3d5f405be47da68e0d0dd55b13897598 /git/refs/symbolic.py | |
parent | c3b7263e0bb9cc1d94e483e66c1494e0e7982fd1 (diff) | |
download | gitpython-fcc166d3a6e235933e823e82e1fcf6160a32a5d3.tar.gz |
log: non-existing logs no longer throw an exception, but are ignored. Fixed critical bug which caused packed-ref files to be written with native line endings, which made git fail to parse it. I wonder why I never noticed this before, or ignored it. Unbelievable \!
Diffstat (limited to 'git/refs/symbolic.py')
-rw-r--r-- | git/refs/symbolic.py | 13 |
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""" |