summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2014-03-12 16:36:07 -0700
committerShawn Pearce <spearce@spearce.org>2014-03-12 16:36:07 -0700
commitd300609495fc52f19535a8d541ec3a848aad3f5d (patch)
tree4e3058df20c19aa4678b47ab20ca3b44990cf2d4
parent0aa682fc68a80704160102fc07dea5611c010746 (diff)
downloadjgit-d300609495fc52f19535a8d541ec3a848aad3f5d.tar.gz
jgit-d300609495fc52f19535a8d541ec3a848aad3f5d.zip
Allow ReceivePack callers to configure their own ObjectChecker
PackParser permits supplying a specific ObjectChecker instance. Allow this to be passed through ReceivePack, giving the caller more flexibility to configure the implementation. Change-Id: I9440dd25588008626222f33bfd697f57c05b439e
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java24
1 files changed, 19 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
index 68b3262a0b..483ac55fa9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
@@ -74,6 +74,7 @@ import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Config.SectionParser;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
+import org.eclipse.jgit.lib.ObjectChecker;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectIdSubclassMap;
import org.eclipse.jgit.lib.ObjectInserter;
@@ -160,7 +161,7 @@ public abstract class BaseReceivePack {
private boolean expectDataAfterPackFooter;
/** Should an incoming transfer validate objects? */
- private boolean checkReceivedObjects;
+ private ObjectChecker objectChecker;
/** Should an incoming transfer permit create requests? */
private boolean allowCreates;
@@ -254,7 +255,7 @@ public abstract class BaseReceivePack {
walk = new RevWalk(db);
final ReceiveConfig cfg = db.getConfig().get(ReceiveConfig.KEY);
- checkReceivedObjects = cfg.checkReceivedObjects;
+ objectChecker = cfg.checkReceivedObjects ? new ObjectChecker() : null;
allowCreates = cfg.allowCreates;
allowDeletes = cfg.allowDeletes;
allowNonFastForwards = cfg.allowNonFastForwards;
@@ -481,16 +482,29 @@ public abstract class BaseReceivePack {
* of the connection.
*/
public boolean isCheckReceivedObjects() {
- return checkReceivedObjects;
+ return objectChecker != null;
}
/**
* @param check
* true to enable checking received objects; false to assume all
* received objects are valid.
+ * @see #setObjectChecker(ObjectChecker)
*/
public void setCheckReceivedObjects(final boolean check) {
- checkReceivedObjects = check;
+ if (check && objectChecker == null)
+ setObjectChecker(new ObjectChecker());
+ else if (!check && objectChecker != null)
+ setObjectChecker(null);
+ }
+
+ /**
+ * @param impl if non-null the object checking instance to verify each
+ * received object with; null to disable object checking.
+ * @since 3.4
+ */
+ public void setObjectChecker(ObjectChecker impl) {
+ objectChecker = impl;
}
/** @return true if the client can request refs to be created. */
@@ -983,7 +997,7 @@ public abstract class BaseReceivePack {
parser.setCheckEofAfterPackFooter(!biDirectionalPipe
&& !isExpectDataAfterPackFooter());
parser.setExpectDataAfterPackFooter(isExpectDataAfterPackFooter());
- parser.setObjectChecking(isCheckReceivedObjects());
+ parser.setObjectChecker(objectChecker);
parser.setLockMessage(lockMsg);
parser.setMaxObjectSizeLimit(maxObjectSizeLimit);
packLock = parser.parse(receiving, resolving);