|
@@ -758,7 +758,7 @@ class BaseRepo(object):
|
|
'filemode = true\n'
|
|
'filemode = true\n'
|
|
'bare = false\n'
|
|
'bare = false\n'
|
|
'logallrefupdates = true\n'))
|
|
'logallrefupdates = true\n'))
|
|
- self._put_named_file('info/exclude', '')
|
|
|
|
|
|
+ self._put_named_file(os.path.join('info', 'exclude'), '')
|
|
|
|
|
|
def get_named_file(self, path):
|
|
def get_named_file(self, path):
|
|
"""Get a file from the control dir with a specific name.
|
|
"""Get a file from the control dir with a specific name.
|
|
@@ -1095,6 +1095,7 @@ class Repo(BaseRepo):
|
|
:param path: The path to the file, relative to the control dir.
|
|
:param path: The path to the file, relative to the control dir.
|
|
:contents: A string to write to the file.
|
|
:contents: A string to write to the file.
|
|
"""
|
|
"""
|
|
|
|
+ path = path.lstrip(os.path.sep)
|
|
f = GitFile(os.path.join(self.controldir(), path), 'wb')
|
|
f = GitFile(os.path.join(self.controldir(), path), 'wb')
|
|
try:
|
|
try:
|
|
f.write(contents)
|
|
f.write(contents)
|
|
@@ -1111,8 +1112,11 @@ class Repo(BaseRepo):
|
|
:param path: The path to the file, relative to the control dir.
|
|
:param path: The path to the file, relative to the control dir.
|
|
:return: An open file object, or None if the file does not exist.
|
|
:return: An open file object, or None if the file does not exist.
|
|
"""
|
|
"""
|
|
|
|
+ # TODO(dborowitz): sanitize filenames, since this is used directly by
|
|
|
|
+ # the dumb web serving code.
|
|
|
|
+ path = path.lstrip(os.path.sep)
|
|
try:
|
|
try:
|
|
- return open(os.path.join(self.controldir(), path.lstrip('/')), 'rb')
|
|
|
|
|
|
+ return open(os.path.join(self.controldir(), path), 'rb')
|
|
except (IOError, OSError), e:
|
|
except (IOError, OSError), e:
|
|
if e.errno == errno.ENOENT:
|
|
if e.errno == errno.ENOENT:
|
|
return None
|
|
return None
|