diff options
author | Shawn Pearce <spearce@spearce.org> | 2014-01-29 14:56:20 -0500 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2014-01-29 14:56:20 -0500 |
commit | abadbabdc5fd81d3ef346b929dc8deb596e34a12 (patch) | |
tree | afa63431ca2a6570fc817da1bc59de852d17d3cd /org.eclipse.jgit/src | |
parent | 85499f38888ebf75e9b6e3db82b8fe4deb152bd4 (diff) | |
parent | b0174a089ce886d02c8d7fb80d63f0e50329bec3 (diff) | |
download | jgit-abadbabdc5fd81d3ef346b929dc8deb596e34a12.tar.gz jgit-abadbabdc5fd81d3ef346b929dc8deb596e34a12.zip |
Merge "Fix serving fetch of existing shallow client"
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java | 12 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java | 6 |
2 files changed, 16 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java index ca5f4fe616..32d4aac75d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java @@ -1308,6 +1308,18 @@ public class RevWalk implements Iterable<RevCommit> { RevCommit.carryFlags(c, carry); } + /** + * Assume additional commits are shallow (have no parents). + * + * @param ids + * commits that should be treated as shallow commits, in addition + * to any commits already known to be shallow by the repository. + */ + public void assumeShallow(Collection<? extends ObjectId> ids) { + for (ObjectId id : ids) + lookupCommit(id).parents = RevCommit.NO_PARENTS; + } + void initializeShallowCommits() throws IOException { if (shallowCommitsInitialized) throw new IllegalStateException( 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 0cc6946b12..b007f2b513 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -684,6 +684,8 @@ public class UploadPack { if (depth != 0) processShallow(); + if (!clientShallowCommits.isEmpty()) + walk.assumeShallow(clientShallowCommits); sendPack = negotiate(); } catch (PackProtocolException err) { reportErrorDuringNegotiate(err.getMessage()); @@ -756,7 +758,7 @@ public class UploadPack { // Commits not on the boundary which are shallow in the client // need to become unshallowed - if (c.getDepth() < depth && clientShallowCommits.contains(c)) { + if (c.getDepth() < depth && clientShallowCommits.remove(c)) { unshallowCommits.add(c.copy()); pckOut.writeString("unshallow " + c.name()); //$NON-NLS-1$ } @@ -1350,7 +1352,7 @@ public class UploadPack { try { pw.setIndexDisabled(true); pw.setUseCachedPacks(true); - pw.setUseBitmaps(true); + pw.setUseBitmaps(depth == 0 && clientShallowCommits.isEmpty()); pw.setReuseDeltaCommits(true); pw.setDeltaBaseAsOffset(options.contains(OPTION_OFS_DELTA)); pw.setThin(options.contains(OPTION_THIN_PACK)); |