소스 검색

Better fix for normalising the case FileSystemBackend.open_repository.

Gary van der Merwe 10 년 전
부모
커밋
f1b483d955
2개의 변경된 파일6개의 추가작업 그리고 8개의 파일을 삭제
  1. 5 5
      dulwich/server.py
  2. 1 3
      dulwich/tests/test_server.py

+ 5 - 5
dulwich/server.py

@@ -185,14 +185,14 @@ class FileSystemBackend(Backend):
 
     def __init__(self, root=os.sep):
         super(FileSystemBackend, self).__init__()
-        self.root = os.path.normcase(
-            (os.path.abspath(root) + os.sep).replace(os.sep * 2, os.sep))
+        self.root = (os.path.abspath(root) + os.sep).replace(os.sep * 2, os.sep)
 
     def open_repository(self, path):
         logger.debug('opening repository at %s', path)
-        abspath = os.path.normcase(
-            os.path.abspath(os.path.join(self.root, path)) + os.sep)
-        if not abspath.startswith(self.root):
+        abspath = os.path.abspath(os.path.join(self.root, path)) + os.sep
+        normcase_abspath = os.path.normcase(abspath)
+        normcase_root = os.path.normcase(self.root)
+        if not normcase_abspath.startswith(normcase_root):
             raise NotGitRepository("Path %r not inside root %r" % (path, self.root))
         return Repo(abspath)
 

+ 1 - 3
dulwich/tests/test_server.py

@@ -841,9 +841,7 @@ class FileSystemBackendTests(TestCase):
 
     def test_absolute(self):
         repo = self.backend.open_repository(self.path)
-        self.assertEqual(
-            os.path.normcase(os.path.abspath(repo.path)),
-            os.path.normcase(os.path.abspath(self.repo.path)))
+        self.assertEqual(os.path.abspath(repo.path), os.path.abspath(self.repo.path))
 
     def test_child(self):
         self.assertRaises(NotGitRepository,