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:35:16 +0200 |
| commit | 90e780a3e16d0c3e4d7288728f6ba36e9c18d736 (patch) | |
| tree | de5988fc3bb6a39b91cc652e9f6cc51f7015087f /git/refs/symbolic.py | |
| parent | 58a930a632c867b65b9a3802e2f4190cf32e33ee (diff) | |
| download | GitPython-90e780a3e16d0c3e4d7288728f6ba36e9c18d736.tar.gz GitPython-90e780a3e16d0c3e4d7288728f6ba36e9c18d736.zip | |
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 | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py index ddee3809..8c3689b4 100644 --- a/git/refs/symbolic.py +++ b/git/refs/symbolic.py @@ -93,7 +93,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: @@ -423,7 +423,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: @@ -450,7 +450,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 @@ -583,7 +586,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 |
