aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/transport
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2020-09-05 22:51:02 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2020-09-05 22:51:34 +0200
commitdaddfe051b1e9fd74af58b72c9b7d3a25b1c6aa3 (patch)
tree3b5a5d70ea875035df9d680e88e0f7c6b1e3c4d9 /org.eclipse.jgit/src/org/eclipse/jgit/transport
parent38015e3d36369c7e43916117df7d0f2f8da8344b (diff)
parentd9b0601d3ace47e97acde83e28f11557e4929fb4 (diff)
downloadjgit-daddfe051b1e9fd74af58b72c9b7d3a25b1c6aa3.tar.gz
jgit-daddfe051b1e9fd74af58b72c9b7d3a25b1c6aa3.zip
Merge branch 'master' into stable-5.9
* master: SshdSession: close channel gracefully jgit: Add DfsBundleWriter Prepare 5.10.0-SNAPSHOT builds ResolveMerger: do not content-merge gitlinks on del/mod conflicts ResolveMerger: Adding test cases for GITLINK deletion ResolveMerger: choose OURS on gitlink when ignoreConflicts ResolveMerger: improving content merge readability ResolveMerger: extracting createGitLinksMergeResult method ResolveMerger: Adding test cases for GITLINK merge Back out the version change to 5.10.0-SNAPSHOT which was done on master already. Change-Id: I1a6b1f0b8f5773be47823d74f593d13b16a601d5 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/transport')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java48
1 files changed, 39 insertions, 9 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java
index 57eed3ad2a..e1aa9d72fb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BundleWriter.java
@@ -17,12 +17,16 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.eclipse.jgit.internal.JGitText;
+import org.eclipse.jgit.internal.storage.pack.CachedPack;
import org.eclipse.jgit.internal.storage.pack.PackWriter;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Constants;
@@ -62,6 +66,8 @@ public class BundleWriter {
private final Set<ObjectId> tagTargets;
+ private final List<CachedPack> cachedPacks = new ArrayList<>();
+
private PackConfig packConfig;
private ObjectCountCallback callback;
@@ -150,6 +156,25 @@ public class BundleWriter {
}
/**
+ * Add objects to the bundle file.
+ *
+ * <p>
+ * When this method is used, object traversal is disabled and specified pack
+ * files are directly saved to the Git bundle file.
+ *
+ * <p>
+ * Unlike {@link #include}, this doesn't affect the refs. Even if the
+ * objects are not reachable from any ref, they will be included in the
+ * bundle file.
+ *
+ * @param c
+ * pack to include
+ */
+ public void addObjectsAsIs(Collection<? extends CachedPack> c) {
+ cachedPacks.addAll(c);
+ }
+
+ /**
* Assume a commit is available on the recipient's side.
* <p>
* In order to fetch from a bundle the recipient must have any assumed
@@ -187,19 +212,24 @@ public class BundleWriter {
try (PackWriter packWriter = newPackWriter()) {
packWriter.setObjectCountCallback(callback);
- final HashSet<ObjectId> inc = new HashSet<>();
- final HashSet<ObjectId> exc = new HashSet<>();
- inc.addAll(include.values());
- for (RevCommit r : assume)
- exc.add(r.getId());
packWriter.setIndexDisabled(true);
packWriter.setDeltaBaseAsOffset(true);
- packWriter.setThin(!exc.isEmpty());
packWriter.setReuseValidatingObjects(false);
- if (exc.isEmpty()) {
- packWriter.setTagTargets(tagTargets);
+ if (cachedPacks.isEmpty()) {
+ HashSet<ObjectId> inc = new HashSet<>();
+ HashSet<ObjectId> exc = new HashSet<>();
+ inc.addAll(include.values());
+ for (RevCommit r : assume) {
+ exc.add(r.getId());
+ }
+ if (exc.isEmpty()) {
+ packWriter.setTagTargets(tagTargets);
+ }
+ packWriter.setThin(!exc.isEmpty());
+ packWriter.preparePack(monitor, inc, exc);
+ } else {
+ packWriter.preparePack(cachedPacks);
}
- packWriter.preparePack(monitor, inc, exc);
final Writer w = new OutputStreamWriter(os, UTF_8);
w.write(TransportBundle.V2_BUNDLE_SIGNATURE);