summaryrefslogtreecommitdiff
path: root/lib/git/config.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-11-15 12:13:59 +0100
committerSebastian Thiel <byronimo@gmail.com>2010-11-15 12:13:59 +0100
commit4d36f8ff4d1274a8815e932285ad6dbd6b2888af (patch)
tree0695bd109d491ffab1cc3890814f0b37a7677405 /lib/git/config.py
parenta1e2f63e64875a29e8c01a7ae17f5744680167a5 (diff)
downloadgitpython-4d36f8ff4d1274a8815e932285ad6dbd6b2888af.tar.gz
Improved GitConfigurationParser to better deal with streams and the corresponding locks. Submodule class now operates on parent_commits, the configuration is either streamed from the repository or written directly into a blob ( or file ) dependending on whether we have a working tree checkout or not which matches our parent_commit
Diffstat (limited to 'lib/git/config.py')
-rw-r--r--lib/git/config.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/git/config.py b/lib/git/config.py
index e919838b..8541dc0e 100644
--- a/lib/git/config.py
+++ b/lib/git/config.py
@@ -271,9 +271,9 @@ class GitConfigParser(cp.RawConfigParser, object):
if not hasattr(file_object, "seek"):
try:
fp = open(file_object)
+ close_fp = True
except IOError,e:
continue
- close_fp = True
# END fp handling
try:
@@ -308,17 +308,21 @@ class GitConfigParser(cp.RawConfigParser, object):
:raise IOError: if this is a read-only writer instance or if we could not obtain
a file lock"""
self._assure_writable("write")
- self._lock._obtain_lock()
-
fp = self._file_or_files
close_fp = False
+ # we have a physical file on disk, so get a lock
+ if isinstance(fp, (basestring, file)):
+ self._lock._obtain_lock()
+ # END get lock for physical files
+
if not hasattr(fp, "seek"):
fp = open(self._file_or_files, "w")
close_fp = True
else:
fp.seek(0)
+ # END handle stream or file
# WRITE DATA
try:
@@ -390,7 +394,7 @@ class GitConfigParser(cp.RawConfigParser, object):
return valuestr
@needs_values
- @set_dirty_and_flush_changes
+ @set_dirty_and_flush_changes
def set_value(self, section, option, value):
"""Sets the given option in section to the given value.
It will create the section if required, and will not throw as opposed to the default