aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorLuca Milanesio <luca.milanesio@gmail.com>2023-06-08 00:21:07 +0100
committerLuca Milanesio <luca.milanesio@gmail.com>2023-06-08 00:21:15 +0100
commita22c62cb6dde1d54a258b672288f11b35baa04a7 (patch)
tree6feca2ced59b11ad2d3781eafaa1f9479cc8a1af /org.eclipse.jgit
parent74a13c7712eaa813d546ec22a301279798b319de (diff)
parentf6928f57362d952b18a99d89d4778ca6ad75e84d (diff)
downloadjgit-a22c62cb6dde1d54a258b672288f11b35baa04a7.tar.gz
jgit-a22c62cb6dde1d54a258b672288f11b35baa04a7.zip
Merge branch 'stable-5.13' into stable-6.0
* stable-5.13: Revert "RefDirectory: Throw exception if CAS of packed ref list fails" Change-Id: I883b21b00317cc6d9951a8a5f9505078ddd2a3a7 Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java17
1 files changed, 1 insertions, 16 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
index b46ffe3670..fbf0ae9cfa 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
@@ -1032,22 +1032,7 @@ public class RefDirectory extends RefDatabase {
byte[] digest = Constants.newMessageDigest().digest(content);
PackedRefList newPackedList = new PackedRefList(
refs, lck.getCommitSnapshot(), ObjectId.fromRaw(digest));
-
- // This thread holds the file lock, so no other thread or process should
- // be able to modify the packed-refs file on disk. If the list changed,
- // it means something is very wrong, so throw an exception.
- //
- // However, we can't use a naive compareAndSet to check whether the
- // update was successful, because another thread might _read_ the
- // packed refs file that was written out by this thread while holding
- // the lock, and update the packedRefs reference to point to that. So
- // compare the actual contents instead.
- PackedRefList afterUpdate = packedRefs.updateAndGet(
- p -> p.id.equals(oldPackedList.id) ? newPackedList : p);
- if (!afterUpdate.id.equals(newPackedList.id)) {
- throw new ObjectWritingException(
- MessageFormat.format(JGitText.get().unableToWrite, name));
- }
+ packedRefs.compareAndSet(oldPackedList, newPackedList);
if (changed) {
modCnt.incrementAndGet();
}