diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java index 9d39f436c..72c169759 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java @@ -222,7 +222,7 @@ public Set getCapabilities() { /** Capabilities requested by the client. */ private Set enabledCapabilities; - + private Set clientShallowCommits; private List commands; private StringBuilder advertiseError; @@ -263,6 +263,7 @@ protected BaseReceivePack(final Repository into) { advertiseRefsHook = AdvertiseRefsHook.DEFAULT; refFilter = RefFilter.DEFAULT; advertisedHaves = new HashSet(); + clientShallowCommits = new HashSet(); } /** Configuration for receive operations. */ @@ -770,6 +771,18 @@ public long getPackSize() { throw new IllegalStateException(JGitText.get().packSizeNotSetYet); } + /** + * Get the commits from the client's shallow file. + * + * @return if the client is a shallow repository, the list of edge commits + * that define the client's shallow boundary. Empty set if the client + * is earlier than Git 1.9, or is a full clone. + * @since 3.5 + */ + protected Set getClientShallowCommits() { + return clientShallowCommits; + } + /** @return true if any commands to be executed have been read. */ protected boolean hasCommands() { return !commands.isEmpty(); @@ -923,6 +936,11 @@ protected void recvCommands() throws IOException { if (line == PacketLineIn.END) break; + if (line.length() >= 48 && line.startsWith("shallow ")) { //$NON-NLS-1$ + clientShallowCommits.add(ObjectId.fromString(line.substring(8, 48))); + continue; + } + if (commands.isEmpty()) { final FirstLine firstLine = new FirstLine(line); enabledCapabilities = firstLine.getCapabilities(); @@ -1030,7 +1048,8 @@ private void receivePack() throws IOException { private boolean needCheckConnectivity() { return isCheckReceivedObjects() - || isCheckReferencedObjectsAreReachable(); + || isCheckReferencedObjectsAreReachable() + || !getClientShallowCommits().isEmpty(); } private void checkConnectivity() throws IOException {