Browse Source

Shallow fetch: Pass along "shallow"s in unparsed-wants case, too

Since 84d2738ff2 (Don't skip want validation when the client sends no
haves, 2013-06-21), this branch is not taken.  Process the
"shallow"s anyway as a defensive measure in case the code path gets
revived.

Change-Id: Idfb834825d77f51e17191c1635c9d78c78738cfd
Signed-off-by: Jonathan Nieder <jrn@google.com>
stable-4.5
Jonathan Nieder 9 years ago
parent
commit
b16e207742
  1. 25
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

25
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java

@ -709,11 +709,32 @@ public class PackWriter implements AutoCloseable {
public void preparePack(ProgressMonitor countingMonitor, public void preparePack(ProgressMonitor countingMonitor,
@NonNull Set<? extends ObjectId> want, @NonNull Set<? extends ObjectId> want,
@NonNull Set<? extends ObjectId> have) throws IOException { @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; ObjectWalk ow;
if (shallowPack) if (shallowPack) {
ow = new DepthWalk.ObjectWalk(reader, depth); ow = new DepthWalk.ObjectWalk(reader, depth);
else } else {
ow = new ObjectWalk(reader); ow = new ObjectWalk(reader);
}
ow.assumeShallow(shallow);
preparePack(countingMonitor, ow, want, have); preparePack(countingMonitor, ow, want, have);
} }

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

@ -1492,7 +1492,7 @@ public class UploadPack {
} }
if (wantAll.isEmpty()) { if (wantAll.isEmpty()) {
pw.preparePack(pm, wantIds, commonBase); pw.preparePack(pm, wantIds, commonBase, clientShallowCommits);
} else { } else {
walk.reset(); walk.reset();

Loading…
Cancel
Save