소스 검색

Cope with \r in ref files on Windows.

Jelmer Vernooij 15 년 전
부모
커밋
bfc3a0dcb6
2개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 0
      NEWS
  2. 3 3
      dulwich/repo.py

+ 3 - 0
NEWS

@@ -13,6 +13,9 @@
 
   * Implement RefsContainer.__contains__. (Jelmer Vernooij)
 
+  * Cope with \r in ref files on Windows. (
+	http://github.com/jelmer/dulwich/issues/#issue/13, Jelmer Vernooij)
+
  FEATURES
 
   * Add include-tag capability to server. (Dave Borowitz)

+ 3 - 3
dulwich/repo.py

@@ -77,7 +77,7 @@ BASE_DIRECTORIES = [
 def read_info_refs(f):
     ret = {}
     for l in f.readlines():
-        (sha, name) = l.rstrip("\n").split("\t", 1)
+        (sha, name) = l.rstrip("\r\n").split("\t", 1)
         ret[name] = sha
     return ret
 
@@ -394,7 +394,7 @@ class DiskRefsContainer(RefsContainer):
                 header = f.read(len(SYMREF))
                 if header == SYMREF:
                     # Read only the first line
-                    return header + iter(f).next().rstrip("\n")
+                    return header + iter(f).next().rstrip("\r\n")
                 else:
                     # Read only the first 40 bytes
                     return header + f.read(40-len(SYMREF))
@@ -586,7 +586,7 @@ def read_packed_refs_with_peeled(f):
     for l in f:
         if l[0] == "#":
             continue
-        l = l.rstrip("\n")
+        l = l.rstrip("\r\n")
         if l[0] == "^":
             if not last:
                 raise PackedRefsException("unexpected peeled ref line")