diff options
| author | Sebastian Thiel <byronimo@gmail.com> | 2011-06-07 21:36:42 +0200 |
|---|---|---|
| committer | Sebastian Thiel <byronimo@gmail.com> | 2011-06-07 21:36:42 +0200 |
| commit | 58a930a632c867b65b9a3802e2f4190cf32e33ee (patch) | |
| tree | 95b1311a3a4bfcdf4c2dba66f360e6985184013e /git/config.py | |
| parent | a98e0af511b728030c12bf8633b077866bb74e47 (diff) | |
| parent | f6897c78be5a5530129df50742cb6cabfb8609c9 (diff) | |
| download | GitPython-58a930a632c867b65b9a3802e2f4190cf32e33ee.tar.gz GitPython-58a930a632c867b65b9a3802e2f4190cf32e33ee.zip | |
Merge branch 'gitdbmerger'
Diffstat (limited to 'git/config.py')
| -rw-r--r-- | git/config.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/git/config.py b/git/config.py index f1a8832e..c71bb8ca 100644 --- a/git/config.py +++ b/git/config.py @@ -120,11 +120,12 @@ class GitConfigParser(cp.RawConfigParser, object): # They must be compatible to the LockFile interface. # A suitable alternative would be the BlockingLockFile t_lock = LockFile + re_comment = re.compile('^\s*[#;]') #} END configuration OPTCRE = re.compile( - r'\s?(?P<option>[^:=\s][^:=]*)' # very permissive, incuding leading whitespace + r'\s*(?P<option>[^:=\s][^:=]*)' # very permissive, incuding leading whitespace r'\s*(?P<vi>[:=])\s*' # any number of space/tab, # followed by separator # (either : or =), followed @@ -211,16 +212,16 @@ class GitConfigParser(cp.RawConfigParser, object): break lineno = lineno + 1 # comment or blank line? - if line.strip() == '' or line[0] in '#;': + if line.strip() == '' or self.re_comment.match(line): continue if line.split(None, 1)[0].lower() == 'rem' and line[0] in "rR": # no leading whitespace continue else: # is it a section header? - mo = self.SECTCRE.match(line) + mo = self.SECTCRE.match(line.strip()) if mo: - sectname = mo.group('header') + sectname = mo.group('header').strip() if sectname in self._sections: cursect = self._sections[sectname] elif sectname == cp.DEFAULTSECT: @@ -332,6 +333,10 @@ class GitConfigParser(cp.RawConfigParser, object): close_fp = True else: fp.seek(0) + # make sure we do not overwrite into an existing file + if hasattr(fp, 'truncate'): + fp.truncate() + #END # END handle stream or file # WRITE DATA |
