]> source.dussan.org Git - jgit.git/commitdiff
Merge changes Ib0d8c294,Idfb83482 44/78644/2
authorJonathan Nieder <jrn@google.com>
Mon, 8 Aug 2016 19:46:56 +0000 (12:46 -0700)
committerJonathan Nieder <jrn@google.com>
Mon, 8 Aug 2016 20:50:57 +0000 (13:50 -0700)
* changes:
  Shallow fetch: Pass along "shallow"s in unparsed-wants case, too
  Shallow fetch: Pass a DepthWalk to PackWriter

Change-Id: I7d1c3b4d0b7ebc254b53404d1618522b0174ac23

1  2 
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

index 16f85166dc74e3b78f9bdde6d2b0975f6175ffb6,ab879fa9e08597f5d98ce8dc5427af16758f93aa..9d331ad9e752d0d0f338e6adeec33d8f09c1b0a1
@@@ -710,11 -709,32 +710,32 @@@ public class PackWriter implements Auto
        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);
 +                      ow = new DepthWalk.ObjectWalk(reader, depth - 1);
-               else
+               } else {
                        ow = new ObjectWalk(reader);
+               }
+               ow.assumeShallow(shallow);
                preparePack(countingMonitor, ow, want, have);
        }
  
index fdadb61d15654abee8ffa3c233c0ddb1839f5a7a,d6c668dbf0ee848d8e095b7a6a63e101cff0d06b..d1fd67e97728cd56c61170d4f35d5f4b8192024f
@@@ -1493,12 -1484,15 +1493,15 @@@ 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 = 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();