From f84370feaaf319b7fe9bd272a7ceba235cc1e86a Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 8 Aug 2016 12:31:39 -0700 Subject: [PATCH] Shallow fetch: Pass a DepthWalk to PackWriter d385a7a5e5ca (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 --- .../src/org/eclipse/jgit/transport/UploadPack.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 e1770f282..6704251e5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -1484,16 +1484,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); + rw.assumeShallow(clientShallowCommits); + } - RevWalk rw = walk; if (wantAll.isEmpty()) { pw.preparePack(pm, wantIds, commonBase); } else { walk.reset(); - ObjectWalk ow = walk.toObjectWalkWithSameObjects(); + ObjectWalk ow = rw.toObjectWalkWithSameObjects(); pw.preparePack(pm, ow, wantAll, commonBase); rw = ow; }