Merge branch 'stable-6.3' into stable-6.4
* stable-6.3: Revert "RefDirectory: Throw exception if CAS of packed ref list fails" Change-Id: I33049e70595f097a66e8f4a63b3d8d1c147e878e Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
This commit is contained in:
commit
b6237ca8b6
|
@ -1052,22 +1052,7 @@ protected void writeFile(String name, byte[] content)
|
||||||
byte[] digest = Constants.newMessageDigest().digest(content);
|
byte[] digest = Constants.newMessageDigest().digest(content);
|
||||||
PackedRefList newPackedList = new PackedRefList(
|
PackedRefList newPackedList = new PackedRefList(
|
||||||
refs, lck.getCommitSnapshot(), ObjectId.fromRaw(digest));
|
refs, lck.getCommitSnapshot(), ObjectId.fromRaw(digest));
|
||||||
|
packedRefs.compareAndSet(oldPackedList, newPackedList);
|
||||||
// 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));
|
|
||||||
}
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
modCnt.incrementAndGet();
|
modCnt.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue