Browse Source

Merge changes from topic 'If72b4b422-cleanup'

* changes:
  UploadPackTest: Fix name hiding introduced by If72b4b422
  Suppress non-localized string warnings introduced by If72b4b422
stable-5.0
Jonathan Nieder 7 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
7719a406bf
  1. 52
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
  2. 4
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java
  3. 7
      org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

52
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java

@ -175,14 +175,14 @@ public class UploadPackTest {
@Test @Test
public void testFetchWithBlobNoneFilter() throws Exception { public void testFetchWithBlobNoneFilter() throws Exception {
InMemoryRepository server2 = newRepo("server2"); InMemoryRepository server2 = newRepo("server2");
TestRepository<InMemoryRepository> remote = TestRepository<InMemoryRepository> remote2 =
new TestRepository<>(server2); new TestRepository<>(server2);
RevBlob blob1 = remote.blob("foobar"); RevBlob blob1 = remote2.blob("foobar");
RevBlob blob2 = remote.blob("fooba"); RevBlob blob2 = remote2.blob("fooba");
RevTree tree = remote.tree( RevTree tree = remote2.tree(remote2.file("1", blob1),
remote.file("1", blob1), remote.file("2", blob2)); remote2.file("2", blob2));
RevCommit commit = remote.commit(tree); RevCommit commit = remote2.commit(tree);
remote.update("master", commit); remote2.update("master", commit);
server2.getConfig().setBoolean("uploadpack", null, "allowfilter", true); server2.getConfig().setBoolean("uploadpack", null, "allowfilter", true);
@ -211,14 +211,14 @@ public class UploadPackTest {
@Test @Test
public void testFetchWithBlobLimitFilter() throws Exception { public void testFetchWithBlobLimitFilter() throws Exception {
InMemoryRepository server2 = newRepo("server2"); InMemoryRepository server2 = newRepo("server2");
TestRepository<InMemoryRepository> remote = TestRepository<InMemoryRepository> remote2 =
new TestRepository<>(server2); new TestRepository<>(server2);
RevBlob longBlob = remote.blob("foobar"); RevBlob longBlob = remote2.blob("foobar");
RevBlob shortBlob = remote.blob("fooba"); RevBlob shortBlob = remote2.blob("fooba");
RevTree tree = remote.tree( RevTree tree = remote2.tree(remote2.file("1", longBlob),
remote.file("1", longBlob), remote.file("2", shortBlob)); remote2.file("2", shortBlob));
RevCommit commit = remote.commit(tree); RevCommit commit = remote2.commit(tree);
remote.update("master", commit); remote2.update("master", commit);
server2.getConfig().setBoolean("uploadpack", null, "allowfilter", true); server2.getConfig().setBoolean("uploadpack", null, "allowfilter", true);
@ -246,14 +246,14 @@ public class UploadPackTest {
@Test @Test
public void testFetchWithBlobLimitFilterAndBitmaps() throws Exception { public void testFetchWithBlobLimitFilterAndBitmaps() throws Exception {
InMemoryRepository server2 = newRepo("server2"); InMemoryRepository server2 = newRepo("server2");
TestRepository<InMemoryRepository> remote = TestRepository<InMemoryRepository> remote2 =
new TestRepository<>(server2); new TestRepository<>(server2);
RevBlob longBlob = remote.blob("foobar"); RevBlob longBlob = remote2.blob("foobar");
RevBlob shortBlob = remote.blob("fooba"); RevBlob shortBlob = remote2.blob("fooba");
RevTree tree = remote.tree( RevTree tree = remote2.tree(remote2.file("1", longBlob),
remote.file("1", longBlob), remote.file("2", shortBlob)); remote2.file("2", shortBlob));
RevCommit commit = remote.commit(tree); RevCommit commit = remote2.commit(tree);
remote.update("master", commit); remote2.update("master", commit);
server2.getConfig().setBoolean("uploadpack", null, "allowfilter", true); server2.getConfig().setBoolean("uploadpack", null, "allowfilter", true);
@ -285,12 +285,12 @@ public class UploadPackTest {
@Test @Test
public void testFetchWithNonSupportingServer() throws Exception { public void testFetchWithNonSupportingServer() throws Exception {
InMemoryRepository server2 = newRepo("server2"); InMemoryRepository server2 = newRepo("server2");
TestRepository<InMemoryRepository> remote = TestRepository<InMemoryRepository> remote2 =
new TestRepository<>(server2); new TestRepository<>(server2);
RevBlob blob = remote.blob("foo"); RevBlob blob = remote2.blob("foo");
RevTree tree = remote.tree(remote.file("1", blob)); RevTree tree = remote2.tree(remote2.file("1", blob));
RevCommit commit = remote.commit(tree); RevCommit commit = remote2.commit(tree);
remote.update("master", commit); remote2.update("master", commit);
server2.getConfig().setBoolean("uploadpack", null, "allowfilter", false); server2.getConfig().setBoolean("uploadpack", null, "allowfilter", false);

4
org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackFetchConnection.java

@ -536,9 +536,9 @@ public abstract class BasePackFetchConnection extends BasePackConnection
return false; return false;
} }
if (filterBlobLimit == 0) { if (filterBlobLimit == 0) {
p.writeString(OPTION_FILTER + " blob:none"); p.writeString(OPTION_FILTER + " blob:none"); //$NON-NLS-1$
} else if (filterBlobLimit > 0) { } else if (filterBlobLimit > 0) {
p.writeString(OPTION_FILTER + " blob:limit=" + filterBlobLimit); p.writeString(OPTION_FILTER + " blob:limit=" + filterBlobLimit); //$NON-NLS-1$
} }
p.end(); p.end();
outNeedsEnd = false; outNeedsEnd = false;

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

@ -1026,11 +1026,12 @@ public class UploadPack {
} }
filterReceived = true; filterReceived = true;
if (arg.equals("blob:none")) { if (arg.equals("blob:none")) { //$NON-NLS-1$
filterBlobLimit = 0; filterBlobLimit = 0;
} else if (arg.startsWith("blob:limit=")) { } else if (arg.startsWith("blob:limit=")) { //$NON-NLS-1$
try { try {
filterBlobLimit = Long.parseLong(arg.substring("blob:limit=".length())); filterBlobLimit = Long.parseLong(
arg.substring("blob:limit=".length())); //$NON-NLS-1$
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new PackProtocolException( throw new PackProtocolException(
MessageFormat.format(JGitText.get().invalidFilter, MessageFormat.format(JGitText.get().invalidFilter,

Loading…
Cancel
Save