diff options
author | Jonathan Nieder <jrn@google.com> | 2016-08-08 12:35:36 -0700 |
---|---|---|
committer | Jonathan Nieder <jrn@google.com> | 2016-08-08 16:49:37 -0400 |
commit | b16e207742beb6a82b2b74df7bb87893a38bdd04 (patch) | |
tree | c8b3afb803c15fcb9987c35605262cd11d6a26d7 /org.eclipse.jgit | |
parent | f84370feaaf319b7fe9bd272a7ceba235cc1e86a (diff) | |
download | jgit-b16e207742beb6a82b2b74df7bb87893a38bdd04.tar.gz jgit-b16e207742beb6a82b2b74df7bb87893a38bdd04.zip |
Shallow fetch: Pass along "shallow"s in unparsed-wants case, too
Since 84d2738ff21c (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>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java | 25 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java | 2 |
2 files changed, 24 insertions, 3 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 106308f4ad..ab879fa9e0 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 @@ -709,11 +709,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); - 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 6704251e56..d6c668dbf0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -1492,7 +1492,7 @@ public class UploadPack { } if (wantAll.isEmpty()) { - pw.preparePack(pm, wantIds, commonBase); + pw.preparePack(pm, wantIds, commonBase, clientShallowCommits); } else { walk.reset(); |