◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
17 changes: 8 additions & 9 deletions git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,15 +406,14 @@ def release(self) -> None:
return

try:
try:
self.write()
except IOError:
log.error("Exception during destruction of GitConfigParser", exc_info=True)
except ReferenceError:
# This happens in PY3 ... and usually means that some state cannot be written
# as the sections dict cannot be iterated
# Usually when shutting down the interpreter, don'y know how to fix this
pass
finally:
if self._lock is not None:
self._lock._release_lock()
Expand Down
8 changes: 3 additions & 5 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,11 @@ def write(
lfd = LockedFD(file_path or self._file_path)
stream = lfd.open(write=True, stream=True)

ok = False
try:
self._serialize(stream, ignore_extension_data)
ok = True
finally:
if not ok:
lfd.rollback()

lfd.commit()

Expand Down
3 changes: 1 addition & 2 deletions git/refs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ def to_file(self, filepath: PathLike) -> None:
try:
self._serialize(fp)
lfd.commit()
except Exception:
# on failure it rolls back automatically, but we make it clear
lfd.rollback()
raise
# END handle change
Expand Down
8 changes: 3 additions & 5 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,12 @@ def set_reference(

lfd = LockedFD(fpath)
fd = lfd.open(write=True, stream=True)
ok = True
try:
fd.write(write_value.encode("utf-8") + b"\n")
lfd.commit()
ok = True
finally:
if not ok:
lfd.rollback()
# Adjust the reflog
if logmsg is not None:
self.log_append(oldbinsha, logmsg)
Expand Down
Toggle all file notes Toggle all file annotations