From d0e4943df1040add984c4fa0b32e791647946b2f Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 14 Jun 2012 12:42:39 -0700 Subject: [PATCH] Allow applications to pass ObjectInserter to Merger Gerrit Code Review needs to control which inserter is used by a Merger. Allow the application to set the inserter before calling merge, giving callers more direct control over how objects will be created. Change-Id: I3c527a493db4659e95289ff3077cffb9e32336cf --- .../src/org/eclipse/jgit/merge/Merger.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java index 35df8e165..fd94cfb23 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java @@ -108,6 +108,8 @@ public abstract class Merger { /** * @return an object writer to create objects in {@link #getRepository()}. + * If no inserter has been set on this instance, one will be created + * and returned by all future calls. */ public ObjectInserter getObjectInserter() { if (inserter == null) @@ -115,6 +117,23 @@ public abstract class Merger { return inserter; } + /** + * Set the inserter this merger will use to create objects. + *

+ * If an inserter was already set on this instance (such as by a prior set, + * or a prior call to {@link #getObjectInserter()}), the prior inserter will + * be released first. + * + * @param oi + * the inserter instance to use. Must be associated with the + * repository instance returned by {@link #getRepository()}. + */ + public void setObjectInserter(ObjectInserter oi) { + if (inserter != null) + inserter.release(); + inserter = oi; + } + /** * Merge together two or more tree-ish objects. *