Skip to content

Commit 48bf6fa

Browse files
committed
Add warning comment for reflog critical section
1 parent c3e58f3 commit 48bf6fa

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lib/reference.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,12 @@ Reference.updateTerminal = function (
163163
})
164164
.then(() => NodeGit.Reflog.read(repo, refName))
165165
.then((reflog) => {
166-
// We may want some kind of transactional logic for this
167-
// There is a theoretical timing issue that could result in updating
168-
// the wrong reflog
166+
// Janky, but works. Ideally, we would want to generate the correct reflog
167+
// entry in the first place, rather than drop the most recent entry and
168+
// write the correct one.
169+
// NOTE: There is a theoretical race condition that could happen here.
170+
// We may want to consider some kind of transactional logic to make sure
171+
// that the reflog on disk isn't modified before we can write back.
169172
reflog.drop(0, 1);
170173
reflog.append(oid, signatureToUse, logMessage);
171174
return reflog.write();

0 commit comments

Comments
 (0)