dulwich-users team mailing list archive
-
dulwich-users team
-
Mailing list archive
-
Message #00406
[PATCH v3 3/4] repo.Repo.get_named_file: normalize case
While we're at it, refactor normalization operations into a separate
function, so we just need to look at one place if we want to change
path normalizations.
---
dulwich/repo.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/dulwich/repo.py b/dulwich/repo.py
index 99c1df8..b1ebd2a 100644
--- a/dulwich/repo.py
+++ b/dulwich/repo.py
@@ -1086,6 +1086,10 @@ class BaseRepo(object):
return c.id
+def _norm_path(path):
+ return os.path.normcase(os.path.realpath(path))
+
+
class Repo(BaseRepo):
"""A git repository backed by local disk."""
@@ -1135,7 +1139,7 @@ class Repo(BaseRepo):
# TODO(dborowitz): sanitize filenames, since this is used directly by
# the dumb web serving code.
path = path.lstrip(os.path.sep)
- path = os.path.realpath(os.path.join(self.controldir(), path))
+ path = _norm_path(os.path.join(self.controldir(), path))
try:
return open(path, 'rb')
except (IOError, OSError), e:
--
1.7.3.2.msysgit.0
Follow ups
References