List of usage examples for org.eclipse.jgit.storage.pack PackConfig PackConfig
public PackConfig(PackConfig cfg)
From source file:com.google.gerrit.server.git.GarbageCollection.java
License:Apache License
private static void logGcConfiguration(Project.NameKey projectName, Repository repo, boolean aggressive) { StringBuilder b = new StringBuilder(); Config cfg = repo.getConfig();/*from w w w .j ava 2s. c om*/ b.append("gc.aggressive=").append(aggressive).append("; "); b.append(formatConfigValues(cfg, ConfigConstants.CONFIG_GC_SECTION, null)); for (String subsection : cfg.getSubsections(ConfigConstants.CONFIG_GC_SECTION)) { b.append(formatConfigValues(cfg, ConfigConstants.CONFIG_GC_SECTION, subsection)); } if (b.length() == 0) { b.append("no set"); } logGcInfo(projectName, "gc config: " + b.toString()); logGcInfo(projectName, "pack config: " + (new PackConfig(repo)).toString()); }
From source file:com.surevine.gateway.scm.git.jgit.BundleWriter.java
License:Eclipse Distribution License
/** * Generate and write the bundle to the output stream. * <p>//from w ww . j a v a2 s .c o m * This method can only be called once per BundleWriter instance. * * @param monitor * progress monitor to report bundle writing status to. * @param os * the stream the bundle is written to. The stream should be * buffered by the caller. The caller is responsible for closing * the stream. * @throws IOException * an error occurred reading a local object's data to include in * the bundle, or writing compressed object data to the output * stream. */ public void writeBundle(ProgressMonitor monitor, OutputStream os) throws IOException { PackConfig pc = packConfig; if (pc == null) pc = new PackConfig(db); PackWriter packWriter = new PackWriter(pc, db.newObjectReader()); try { final HashSet<ObjectId> inc = new HashSet<ObjectId>(); final HashSet<ObjectId> exc = new HashSet<ObjectId>(); inc.addAll(include.values()); for (final RevCommit r : assume) exc.add(r.getId()); packWriter.setIndexDisabled(true); packWriter.setDeltaBaseAsOffset(true); packWriter.setThin(exc.size() > 0); packWriter.setReuseValidatingObjects(false); if (exc.size() == 0) packWriter.setTagTargets(tagTargets); packWriter.preparePack(monitor, inc, exc); final Writer w = new OutputStreamWriter(os, Constants.CHARSET); w.write(TransportBundle.V2_BUNDLE_SIGNATURE); w.write('\n'); final char[] tmp = new char[Constants.OBJECT_ID_STRING_LENGTH]; for (final RevCommit a : assume) { w.write('-'); a.copyTo(tmp, w); if (a.getRawBuffer() != null) { w.write(' '); w.write(a.getShortMessage()); } w.write('\n'); } for (final Map.Entry<String, ObjectId> e : include.entrySet()) { e.getValue().copyTo(tmp, w); w.write(' '); w.write(e.getKey()); w.write('\n'); } w.write('\n'); w.flush(); packWriter.writePack(monitor, monitor, os); } finally { packWriter.release(); } }