Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commitd40320b

Browse files
authored
Merge pull request#1675 from EliahKagan/rollback
Fix rollback bug in SymbolicReference.set_reference
2 parentsd1c1f31 +e480985 commitd40320b

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

‎git/config.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,14 @@ def release(self) -> None:
406406
return
407407

408408
try:
409-
try:
410-
self.write()
411-
exceptIOError:
412-
log.error("Exception during destruction of GitConfigParser",exc_info=True)
413-
exceptReferenceError:
414-
# This happens in PY3 ... and usually means that some state cannot be written
415-
# as the sections dict cannot be iterated
416-
# Usually when shutting down the interpreter, don'y know how to fix this
417-
pass
409+
self.write()
410+
exceptIOError:
411+
log.error("Exception during destruction of GitConfigParser",exc_info=True)
412+
exceptReferenceError:
413+
# This happens in PY3 ... and usually means that some state cannot be
414+
# written as the sections dict cannot be iterated
415+
# Usually when shutting down the interpreter, don't know how to fix this
416+
pass
418417
finally:
419418
ifself._lockisnotNone:
420419
self._lock._release_lock()

‎git/index/base.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,11 @@ def write(
224224
lfd=LockedFD(file_pathorself._file_path)
225225
stream=lfd.open(write=True,stream=True)
226226

227-
ok=False
228227
try:
229228
self._serialize(stream,ignore_extension_data)
230-
ok=True
231-
finally:
232-
ifnotok:
233-
lfd.rollback()
229+
exceptBaseException:
230+
lfd.rollback()
231+
raise
234232

235233
lfd.commit()
236234

‎git/refs/log.py

Lines 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-
exceptException:
266-
# on failure it rolls back automatically, but we make it clear
265+
exceptBaseException:
267266
lfd.rollback()
268267
raise
269268
# END handle change

‎git/refs/symbolic.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,12 @@ def set_reference(
370370

371371
lfd=LockedFD(fpath)
372372
fd=lfd.open(write=True,stream=True)
373-
ok=True
374373
try:
375374
fd.write(write_value.encode("utf-8")+b"\n")
376375
lfd.commit()
377-
ok=True
378-
finally:
379-
ifnotok:
380-
lfd.rollback()
376+
exceptBaseException:
377+
lfd.rollback()
378+
raise
381379
# Adjust the reflog
382380
iflogmsgisnotNone:
383381
self.log_append(oldbinsha,logmsg)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp