summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2016-08-08 12:46:56 -0700
committerJonathan Nieder <jrn@google.com>2016-08-08 13:50:57 -0700
commit3b0b7677fffa1fe826485f383e6b724703742d08 (patch)
treefef3ebef930983084a3cafaa3f2d361493da6ed8
parentb4d33382253efa42d92245d09995b093ec6089ad (diff)
parentb16e207742beb6a82b2b74df7bb87893a38bdd04 (diff)
downloadjgit-3b0b7677fffa1fe826485f383e6b724703742d08.tar.gz
jgit-3b0b7677fffa1fe826485f383e6b724703742d08.zip
Merge changes Ib0d8c294,Idfb83482
* changes: Shallow fetch: Pass along "shallow"s in unparsed-wants case, too Shallow fetch: Pass a DepthWalk to PackWriter Change-Id: I7d1c3b4d0b7ebc254b53404d1618522b0174ac23
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java25
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java11
2 files changed, 30 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
index 16f85166dc..9d331ad9e7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
@@ -710,11 +710,32 @@ public class PackWriter implements AutoCloseable {
public void preparePack(ProgressMonitor countingMonitor,
@NonNull Set<? extends ObjectId> want,
@NonNull Set<? extends ObjectId> have) throws IOException {
+ preparePack(countingMonitor,
+ want, have, Collections.<ObjectId> emptySet());
+ }
+
+ /**
+ * Prepare the list of objects to be written to the pack stream.
+ * <p>
+ * Like {@link #preparePack(ProgressMonitor, Set, Set)} but also allows
+ * specifying commits that should not be walked past ("shallow" commits).
+ * The caller is responsible for filtering out commits that should not
+ * be shallow any more ("unshallow" commits as in {@link #setShallowPack})
+ * from the shallow set.
+ *
+ * @since 4.5
+ */
+ public void preparePack(ProgressMonitor countingMonitor,
+ @NonNull Set<? extends ObjectId> want,
+ @NonNull Set<? extends ObjectId> have,
+ @NonNull Set<? extends ObjectId> shallow) throws IOException {
ObjectWalk ow;
- if (shallowPack)
+ if (shallowPack) {
ow = new DepthWalk.ObjectWalk(reader, depth - 1);
- else
+ } else {
ow = new ObjectWalk(reader);
+ }
+ ow.assumeShallow(shallow);
preparePack(countingMonitor, ow, want, have);
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index fdadb61d15..d1fd67e977 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -1493,16 +1493,19 @@ public class UploadPack {
pw.setTagTargets(tagTargets);
}
- if (depth > 0)
+ RevWalk rw = walk;
+ if (depth > 0) {
pw.setShallowPack(depth, unshallowCommits);
+ rw = new DepthWalk.RevWalk(walk.getObjectReader(), depth - 1);
+ rw.assumeShallow(clientShallowCommits);
+ }
- RevWalk rw = walk;
if (wantAll.isEmpty()) {
- pw.preparePack(pm, wantIds, commonBase);
+ pw.preparePack(pm, wantIds, commonBase, clientShallowCommits);
} else {
walk.reset();
- ObjectWalk ow = walk.toObjectWalkWithSameObjects();
+ ObjectWalk ow = rw.toObjectWalkWithSameObjects();
pw.preparePack(pm, ow, wantAll, commonBase);
rw = ow;
}