aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackedBatchRefUpdate.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java15
2 files changed, 24 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackedBatchRefUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackedBatchRefUpdate.java
index 9c1d33dc3c..8b0ea4fcd6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackedBatchRefUpdate.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackedBatchRefUpdate.java
@@ -86,10 +86,16 @@ import org.eclipse.jgit.util.RefList;
*/
class PackedBatchRefUpdate extends BatchRefUpdate {
private RefDirectory refdb;
+ private boolean shouldLockLooseRefs;
PackedBatchRefUpdate(RefDirectory refdb) {
- super(refdb);
- this.refdb = refdb;
+ this(refdb, true);
+ }
+
+ PackedBatchRefUpdate(RefDirectory refdb, boolean shouldLockLooseRefs) {
+ super(refdb);
+ this.refdb = refdb;
+ this.shouldLockLooseRefs = shouldLockLooseRefs;
}
/** {@inheritDoc} */
@@ -155,7 +161,7 @@ class PackedBatchRefUpdate extends BatchRefUpdate {
refdb.inProcessPackedRefsLock.lock();
try {
PackedRefList oldPackedList;
- if (!refdb.isInClone()) {
+ if (!refdb.isInClone() && shouldLockLooseRefs) {
locks = lockLooseRefs(pending);
if (locks == null) {
return;
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 07e38147f7..b46ffe3670 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
@@ -587,6 +587,21 @@ public class RefDirectory extends RefDatabase {
return new PackedBatchRefUpdate(this);
}
+ /**
+ * Create a new batch update to attempt on this database.
+ *
+ * @param shouldLockLooseRefs
+ * whether loose refs should be locked during the batch ref
+ * update. Note that this should only be set to {@code false} if
+ * the application using this ensures that no other ref updates
+ * run concurrently to avoid lost updates caused by a race. In
+ * such cases it can improve performance.
+ * @return a new batch update object
+ */
+ public PackedBatchRefUpdate newBatchUpdate(boolean shouldLockLooseRefs) {
+ return new PackedBatchRefUpdate(this, shouldLockLooseRefs);
+ }
+
/** {@inheritDoc} */
@Override
public boolean performsAtomicTransactions() {