Browse Source

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
stable-2.1
Shawn O. Pearce 13 years ago
parent
commit
d0e4943df1
  1. 19
      org.eclipse.jgit/src/org/eclipse/jgit/merge/Merger.java

19
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()}. * @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() { public ObjectInserter getObjectInserter() {
if (inserter == null) if (inserter == null)
@ -115,6 +117,23 @@ public abstract class Merger {
return inserter; return inserter;
} }
/**
* Set the inserter this merger will use to create objects.
* <p>
* 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. * Merge together two or more tree-ish objects.
* <p> * <p>

Loading…
Cancel
Save