Browse Source

ReceivePack: Pass atomic setting from client to BatchRefUpdate

Change-Id: I0e4e6cef693e8138562f5ca345e0db61a8abef9c
stable-4.5
Jonathan Nieder 9 years ago
parent
commit
73b3c9c1d8
  1. 26
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

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

@ -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);

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

@ -201,6 +201,8 @@ public class ReceivePack extends BaseReceivePack {
if (unpackError == null) {
boolean atomic = isCapabilityEnabled(CAPABILITY_ATOMIC);
setAtomic(atomic);
validateCommands();
if (atomic && anyRejects())
failPendingCommands();

Loading…
Cancel
Save