aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2018-10-02 15:18:43 -0700
committerJonathan Tan <jonathantanmy@google.com>2018-10-23 11:10:07 -0700
commitf5fa1eaf399275e9cc4a6418ecadfa04c10060b6 (patch)
treec9918505201e62dacba602add988d6b6e63f640a /org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
parenta579a56e3ae2e5ab6b3287c4450fe6c59ebc85e7 (diff)
downloadjgit-f5fa1eaf399275e9cc4a6418ecadfa04c10060b6.tar.gz
jgit-f5fa1eaf399275e9cc4a6418ecadfa04c10060b6.zip
Throw error when deepen-since excludes all commits
In C Git, when a client fetches with "git fetch --shallow-since=<date> origin <ref>", and all commits reachable from <ref> are older than <date>, the server dies with a message "no commits selected for shallow requests". That is, (1) the --shallow-since filter applies to the commit pointed to by the ref itself, and (2) there is a check that at least one commit is not filtered out. (The pack-protocol.txt documentation does not describe this, but the C implementation does this.) The implementation in commit 1bb430dc21 ("UploadPack: support deepen-since in protocol v2", 2018-09-27) does neither (1) nor (2), so do both of these. Change-Id: I9946327a71627626ecce34ca2d017d2add8867fc Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
index b74dcca583..ad3eb2e322 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
@@ -1280,6 +1280,26 @@ public class UploadPackTest {
}
@Test
+ public void testV2FetchShallowSince_noCommitsSelected() throws Exception {
+ PersonIdent person = new PersonIdent(remote.getRepository());
+
+ RevCommit tooOld = remote.commit()
+ .committer(new PersonIdent(person, 1500000000, 0)).create();
+
+ remote.update("branch1", tooOld);
+
+ thrown.expect(PackProtocolException.class);
+ thrown.expectMessage("No commits selected for shallow request");
+ uploadPackV2(
+ "command=fetch\n",
+ PacketLineIn.DELIM,
+ "deepen-since 1510000\n",
+ "want " + tooOld.toObjectId().getName() + "\n",
+ "done\n",
+ PacketLineIn.END);
+ }
+
+ @Test
public void testV2FetchUnrecognizedArgument() throws Exception {
thrown.expect(PackProtocolException.class);
thrown.expectMessage("unexpected invalid-argument");