Browse Source

Shallow fetch: Pass a DepthWalk to PackWriter

d385a7a5e5 (Shallow fetch: Respect "shallow" lines, 2016-08-03) forgot
that UploadPack wasn't passing a DepthWalk to PackWriter in the first
place.  As a result, shallow clones fail:

  java.lang.IllegalArgumentException: Shallow packs require a DepthWalk
        at org.eclipse.jgit.internal.storage.pack.PackWriter.preparePack(PackWriter.java:756)
        at org.eclipse.jgit.transport.UploadPack.sendPack(UploadPack.java:1497)
        at org.eclipse.jgit.transport.UploadPack.sendPack(UploadPack.java:1381)
        at org.eclipse.jgit.transport.UploadPack.service(UploadPack.java:774)
        at org.eclipse.jgit.transport.UploadPack.upload(UploadPack.java:667)
        at org.eclipse.jgit.http.server.UploadPackServlet.doPost(UploadPackServlet.java:191)

Change-Id: Ib0d8c2946eebfea910a2b767fb92e23da15d4749
stable-4.5
Jonathan Nieder 8 years ago
parent
commit
f84370feaa
  1. 9
      org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

9
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

@ -1484,16 +1484,19 @@ public class UploadPack {
pw.setTagTargets(tagTargets); pw.setTagTargets(tagTargets);
} }
if (depth > 0) RevWalk rw = walk;
if (depth > 0) {
pw.setShallowPack(depth, unshallowCommits); pw.setShallowPack(depth, unshallowCommits);
rw = new DepthWalk.RevWalk(walk.getObjectReader(), depth);
rw.assumeShallow(clientShallowCommits);
}
RevWalk rw = walk;
if (wantAll.isEmpty()) { if (wantAll.isEmpty()) {
pw.preparePack(pm, wantIds, commonBase); pw.preparePack(pm, wantIds, commonBase);
} else { } else {
walk.reset(); walk.reset();
ObjectWalk ow = walk.toObjectWalkWithSameObjects(); ObjectWalk ow = rw.toObjectWalkWithSameObjects();
pw.preparePack(pm, ow, wantAll, commonBase); pw.preparePack(pm, ow, wantAll, commonBase);
rw = ow; rw = ow;
} }

Loading…
Cancel
Save