]> source.dussan.org Git - jgit.git/commitdiff
ReceivePack: Pass atomic setting from client to BatchRefUpdate 93/72093/1
authorJonathan Nieder <jrn@google.com>
Wed, 4 May 2016 21:00:42 +0000 (14:00 -0700)
committerJonathan Nieder <jrn@google.com>
Wed, 4 May 2016 21:00:42 +0000 (14:00 -0700)
Change-Id: I0e4e6cef693e8138562f5ca345e0db61a8abef9c

org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

index a20e652553ec2fa75873a3452f1a612fff192cf8..8ed64ea823e7b9c0e9040cdc1f502c7be91f5567 100644 (file)
@@ -176,6 +176,12 @@ public abstract class BaseReceivePack {
        /** Should an incoming transfer permit non-fast-forward requests? */
        private boolean allowNonFastForwards;
 
+       /**
+        * Should the requested ref updates be performed as a single atomic
+        * transaction?
+        */
+       private boolean atomic;
+
        private boolean allowOfsDelta;
        private boolean allowQuiet = true;
 
@@ -607,6 +613,25 @@ public abstract class BaseReceivePack {
                allowNonFastForwards = canRewind;
        }
 
+       /**
+        * @return true if the client's commands should be performed as a single
+        *         atomic transaction.
+        * @since 4.4
+        */
+       public boolean isAtomic() {
+               return atomic;
+       }
+
+       /**
+        * @param atomic
+        *            true to perform the client's commands as a single atomic
+        *            transaction.
+        * @since 4.4
+        */
+       protected void setAtomic(boolean atomic) {
+               this.atomic = atomic;
+       }
+
        /** @return identity of the user making the changes in the reflog. */
        public PersonIdent getRefLogIdent() {
                return refLogIdent;
@@ -1483,6 +1508,7 @@ public abstract class BaseReceivePack {
 
                BatchRefUpdate batch = db.getRefDatabase().newBatchUpdate();
                batch.setAllowNonFastForwards(isAllowNonFastForwards());
+               batch.setAtomic(isAtomic());
                batch.setRefLogIdent(getRefLogIdent());
                batch.setRefLogMessage("push", true); //$NON-NLS-1$
                batch.addCommand(toApply);
index 6ed9bc8f17763cf44dc2d6587ae3048e05d8c863..f61e93fff29f7f2f71639a18b262e67a9faf9825 100644 (file)
@@ -201,6 +201,8 @@ public class ReceivePack extends BaseReceivePack {
 
                        if (unpackError == null) {
                                boolean atomic = isCapabilityEnabled(CAPABILITY_ATOMIC);
+                               setAtomic(atomic);
+
                                validateCommands();
                                if (atomic && anyRejects())
                                        failPendingCommands();