Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e480985

Browse filesBrowse files
committed
Tweak rollback logic in log.to_file
This modifies the exception handling in log.to_file so it catches BaseException rather than Exception and rolls back. Ordinarily we do not want to catch BaseException, since this means catching things like SystemExit, KeyboardInterupt, etc., but the other cases of rolling back with LockedFD do it that strongly (both before when try-finally was used with a flag, and now with try-except catching BaseException to roll back the temporary-file write and reraise). Having this behave subtly different does not appear intentional. (This is also closer to what will happen if LockedFD becomes a context manager and these pieces of code use it in a with-statement: even exceptions not inheriting from Exception will cause __exit__ to be called.)
1 parent ff84b26 commit e480985
Copy full SHA for e480985

File tree

1 file changed

+1
-2
lines changed
Filter options

1 file changed

+1
-2
lines changed

‎git/refs/log.py

Copy file name to clipboardExpand all lines: git/refs/log.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ def to_file(self, filepath: PathLike) -> None:
262262
try:
263263
self._serialize(fp)
264264
lfd.commit()
265-
except Exception:
266-
# on failure it rolls back automatically, but we make it clear
265+
except BaseException:
267266
lfd.rollback()
268267
raise
269268
# END handle change

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.