From 592ec8492326ccef7b4af022bffcc385eac8adb8 Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Thu, 21 Sep 2023 06:57:27 -0400 Subject: [PATCH] Fix rollback bug in SymbolicReference.set_reference This fixes the initialization of the "ok" flag by setting it to False before the operation that might fail is attempted. (This is a fix for the *specific* problem reported in #1669 about how the pattern SymbolicReference.set_reference attempts to use with LockedFD is not correctly implemented.) --- git/refs/symbolic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py index 5c293aa7b..6361713de 100644 --- a/git/refs/symbolic.py +++ b/git/refs/symbolic.py @@ -370,7 +370,7 @@ def set_reference( lfd = LockedFD(fpath) fd = lfd.open(write=True, stream=True) - ok = True + ok = False try: fd.write(write_value.encode("utf-8") + b"\n") lfd.commit()