summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2019-06-02 11:04:59 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2019-06-02 18:32:59 +0900
commit7377b8dd01b56caa85b47e5b2da32a9b784315d3 (patch)
treea291f75e9af837c68b35f612cabf54cedd70957a
parent07a07a75d6c22458bb94dffc3498a6472222026f (diff)
downloadjgit-7377b8dd01b56caa85b47e5b2da32a9b784315d3.tar.gz
jgit-7377b8dd01b56caa85b47e5b2da32a9b784315d3.zip
Replace trivial reference comparison of PacketLineIn.{DELIM,END}
Replace reference comparisons of PacketLineIn's DELIM and END strings with usage of the helper methods isDelimiter() and isEnd(). Change-Id: I52dcfc4ee9097f1bd6970601c716701847d9eebd Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java3
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java4
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV0ParserTest.java4
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java4
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java24
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefAdvertiserTest.java4
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java63
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV0Parser.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java10
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java2
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java4
14 files changed, 64 insertions, 66 deletions
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
index 1660f14f34..4158049171 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HttpClientTests.java
@@ -44,7 +44,6 @@
package org.eclipse.jgit.http.test;
import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.theInstance;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -366,7 +365,7 @@ public class HttpClientTests extends HttpTestCase {
// Check that we get a v0 response.
assertThat(pckIn.readString(), is("# service=git-upload-pack"));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.END));
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
assertTrue(pckIn.readString().matches("[0-9a-f]{40} HEAD.*"));
}
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java
index f0fac5ab51..6a3d8829bb 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/ProtocolErrorTest.java
@@ -44,7 +44,7 @@
package org.eclipse.jgit.http.test;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -157,7 +157,7 @@ public class ProtocolErrorTest extends HttpTestCase {
pckin.readString());
assertEquals("ng refs/objects/A n/a (unpacker error)",
pckin.readString());
- assertSame(PacketLineIn.END, pckin.readString());
+ assertTrue(PacketLineIn.isEnd(pckin.readString()));
}
} finally {
c.disconnect();
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV0ParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV0ParserTest.java
index 28a9c03ecc..42553147fb 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV0ParserTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV0ParserTest.java
@@ -64,9 +64,9 @@ public class ProtocolV0ParserTest {
ByteArrayOutputStream send = new ByteArrayOutputStream();
PacketLineOut pckOut = new PacketLineOut(send);
for (String line : inputLines) {
- if (line == PacketLineIn.END) {
+ if (PacketLineIn.isEnd(line)) {
pckOut.end();
- } else if (line == PacketLineIn.DELIM) {
+ } else if (PacketLineIn.isDelimiter(line)) {
pckOut.writeDelim();
} else {
pckOut.writeString(line);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java
index 7d6e300fd3..43da170b69 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java
@@ -123,9 +123,9 @@ public class ProtocolV2ParserTest {
ByteArrayOutputStream send = new ByteArrayOutputStream();
PacketLineOut pckOut = new PacketLineOut(send);
for (String line : inputLines) {
- if (line == PacketLineIn.END) {
+ if (PacketLineIn.isEnd(line)) {
pckOut.end();
- } else if (line == PacketLineIn.DELIM) {
+ } else if (PacketLineIn.isDelimiter(line)) {
pckOut.writeDelim();
} else {
pckOut.writeString(line);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java
index 50c8a29543..5d208eea73 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java
@@ -306,11 +306,11 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas
int nul = master.indexOf('\0');
assertTrue("has capability list", nul > 0);
assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
- assertSame(PacketLineIn.END, r.readString());
+ assertTrue(PacketLineIn.isEnd(r.readString()));
assertEquals("unpack error Missing commit " + P.name(), r.readString());
assertEquals("ng refs/heads/s n/a (unpacker error)", r.readString());
- assertSame(PacketLineIn.END, r.readString());
+ assertTrue(PacketLineIn.isEnd(r.readString()));
}
private static void receive(final ReceivePack rp,
@@ -366,13 +366,13 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas
int nul = master.indexOf('\0');
assertTrue("has capability list", nul > 0);
assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
- assertSame(PacketLineIn.END, r.readString());
+ assertTrue(PacketLineIn.isEnd(r.readString()));
assertEquals("unpack error Missing blob " + b.name(),
r.readString());
assertEquals("ng refs/heads/s n/a (unpacker error)",
r.readString());
- assertSame(PacketLineIn.END, r.readString());
+ assertTrue(PacketLineIn.isEnd(r.readString()));
}
}
@@ -419,13 +419,13 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas
int nul = master.indexOf('\0');
assertTrue("has capability list", nul > 0);
assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
- assertSame(PacketLineIn.END, r.readString());
+ assertTrue(PacketLineIn.isEnd(r.readString()));
assertEquals("unpack error Missing blob " + b.name(),
r.readString());
assertEquals("ng refs/heads/s n/a (unpacker error)",
r.readString());
- assertSame(PacketLineIn.END, r.readString());
+ assertTrue(PacketLineIn.isEnd(r.readString()));
}
}
@@ -473,13 +473,13 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas
int nul = master.indexOf('\0');
assertTrue("has capability list", nul > 0);
assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
- assertSame(PacketLineIn.END, r.readString());
+ assertTrue(PacketLineIn.isEnd(r.readString()));
assertEquals("unpack error Missing blob " + n.name(),
r.readString());
assertEquals("ng refs/heads/s n/a (unpacker error)",
r.readString());
- assertSame(PacketLineIn.END, r.readString());
+ assertTrue(PacketLineIn.isEnd(r.readString()));
}
}
@@ -504,13 +504,13 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas
int nul = master.indexOf('\0');
assertTrue("has capability list", nul > 0);
assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
- assertSame(PacketLineIn.END, r.readString());
+ assertTrue(PacketLineIn.isEnd(r.readString()));
String errorLine = r.readString();
assertTrue(errorLine.startsWith("unpack error"));
assertTrue(errorLine.contains("Invalid submodule URL '-"));
assertEquals("ng refs/heads/s n/a (unpacker error)", r.readString());
- assertSame(PacketLineIn.END, r.readString());
+ assertTrue(PacketLineIn.isEnd(r.readString()));
}
private TemporaryBuffer.Heap setupSourceRepoInvalidGitmodules()
@@ -589,13 +589,13 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas
int nul = master.indexOf('\0');
assertTrue("has capability list", nul > 0);
assertEquals(B.name() + ' ' + R_MASTER, master.substring(0, nul));
- assertSame(PacketLineIn.END, r.readString());
+ assertTrue(PacketLineIn.isEnd(r.readString()));
assertEquals("unpack error Missing tree " + t.name(),
r.readString());
assertEquals("ng refs/heads/s n/a (unpacker error)",
r.readString());
- assertSame(PacketLineIn.END, r.readString());
+ assertTrue(PacketLineIn.isEnd(r.readString()));
}
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefAdvertiserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefAdvertiserTest.java
index ce69adf9c1..ccb548d919 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefAdvertiserTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/RefAdvertiserTest.java
@@ -45,7 +45,7 @@ package org.eclipse.jgit.transport;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -95,7 +95,7 @@ public class RefAdvertiserTest {
assertEquals(id(3).name() + " refs/Iñtërnâtiônàlizætiøn☃💩\n", s);
s = pckIn.readStringRaw();
- assertSame(PacketLineIn.END, s);
+ assertTrue(PacketLineIn.isEnd(s));
}
private static ObjectId id(int i) {
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 3ead31dbd7..0ad1e2152c 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
@@ -4,7 +4,6 @@ import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.theInstance;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -428,9 +427,9 @@ public class UploadPackTest {
try (ByteArrayOutputStream send = new ByteArrayOutputStream()) {
PacketLineOut pckOut = new PacketLineOut(send);
for (String line : inputLines) {
- if (line == PacketLineIn.END) {
+ if (PacketLineIn.isEnd(line)) {
pckOut.end();
- } else if (line == PacketLineIn.DELIM) {
+ } else if (PacketLineIn.isDelimiter(line)) {
pckOut.writeDelim();
} else {
pckOut.writeString(line);
@@ -453,7 +452,7 @@ public class UploadPackTest {
PacketLineIn pckIn = new PacketLineIn(recvStream);
// drain capabilities
- while (pckIn.readString() != PacketLineIn.END) {
+ while (!PacketLineIn.isEnd(pckIn.readString())) {
// do nothing
}
return recvStream;
@@ -504,7 +503,7 @@ public class UploadPackTest {
// and additional capabilities to be added to existing
// commands without requiring test changes.
hasItems("ls-refs", "fetch=shallow", "server-option"));
- assertTrue(pckIn.readString() == PacketLineIn.END);
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -521,7 +520,7 @@ public class UploadPackTest {
// TODO(jonathantanmy) This check overspecifies the
// order of the capabilities of "fetch".
hasItems("ls-refs", "fetch=filter shallow", "server-option"));
- assertTrue(pckIn.readString() == PacketLineIn.END);
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -539,7 +538,7 @@ public class UploadPackTest {
// order of the capabilities of "fetch".
hasItems("ls-refs", "fetch=ref-in-want shallow",
"server-option"));
- assertTrue(pckIn.readString() == PacketLineIn.END);
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -554,7 +553,7 @@ public class UploadPackTest {
Arrays.asList(pckIn.readString(), pckIn.readString(),
pckIn.readString()),
hasItems("ls-refs", "fetch=shallow", "server-option"));
- assertTrue(pckIn.readString() == PacketLineIn.END);
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -570,7 +569,7 @@ public class UploadPackTest {
Arrays.asList(pckIn.readString(), pckIn.readString(),
pckIn.readString()),
hasItems("ls-refs", "fetch=shallow", "server-option"));
- assertTrue(pckIn.readString() == PacketLineIn.END);
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -598,7 +597,7 @@ public class UploadPackTest {
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " HEAD"));
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/master"));
assertThat(pckIn.readString(), is(tag.toObjectId().getName() + " refs/tags/tag"));
- assertTrue(pckIn.readString() == PacketLineIn.END);
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -615,7 +614,7 @@ public class UploadPackTest {
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " HEAD symref-target:refs/heads/master"));
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/master"));
assertThat(pckIn.readString(), is(tag.toObjectId().getName() + " refs/tags/tag"));
- assertTrue(pckIn.readString() == PacketLineIn.END);
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -635,7 +634,7 @@ public class UploadPackTest {
pckIn.readString(),
is(tag.toObjectId().getName() + " refs/tags/tag peeled:"
+ tip.toObjectId().getName()));
- assertTrue(pckIn.readString() == PacketLineIn.END);
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -657,11 +656,11 @@ public class UploadPackTest {
pckIn.readString(),
is(tag.toObjectId().getName() + " refs/tags/tag peeled:"
+ tip.toObjectId().getName()));
- assertTrue(pckIn.readString() == PacketLineIn.END);
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " HEAD"));
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/master"));
assertThat(pckIn.readString(), is(tag.toObjectId().getName() + " refs/tags/tag"));
- assertTrue(pckIn.readString() == PacketLineIn.END);
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -681,7 +680,7 @@ public class UploadPackTest {
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/master"));
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/other"));
- assertTrue(pckIn.readString() == PacketLineIn.END);
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -700,7 +699,7 @@ public class UploadPackTest {
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/master"));
assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/other"));
- assertTrue(pckIn.readString() == PacketLineIn.END);
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -908,7 +907,7 @@ public class UploadPackTest {
assertThat(pckIn.readString(), is("acknowledgments"));
assertThat(pckIn.readString(), is("ACK " + fooParent.toObjectId().getName()));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.END));
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -937,7 +936,7 @@ public class UploadPackTest {
"ACK " + fooParent.toObjectId().getName(),
"ACK " + barParent.toObjectId().getName()));
assertThat(pckIn.readString(), is("ready"));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
assertFalse(client.getObjectDatabase().has(fooParent.toObjectId()));
@@ -1160,7 +1159,7 @@ public class UploadPackTest {
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("shallow-info"));
assertThat(pckIn.readString(), is("shallow " + child.toObjectId().getName()));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
assertTrue(client.getObjectDatabase().has(child.toObjectId()));
@@ -1198,7 +1197,7 @@ public class UploadPackTest {
// sent only if a packfile is sent.
assertThat(pckIn.readString(), is("acknowledgments"));
assertThat(pckIn.readString(), is("NAK"));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.END));
+ assertTrue(PacketLineIn.isEnd(pckIn.readString()));
}
@Test
@@ -1237,7 +1236,7 @@ public class UploadPackTest {
// later than the given deepen-since time.
assertThat(pckIn.readString(), is("unshallow " + boundary.toObjectId().getName()));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
@@ -1286,7 +1285,7 @@ public class UploadPackTest {
"shallow " + child1.toObjectId().getName(),
"shallow " + child2.toObjectId().getName()));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
@@ -1353,7 +1352,7 @@ public class UploadPackTest {
// "three" is unshallow because its parent "two" is now available.
assertThat(pckIn.readString(), is("unshallow " + three.toObjectId().getName()));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
@@ -1413,7 +1412,7 @@ public class UploadPackTest {
PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("shallow-info"));
assertThat(pckIn.readString(), is("shallow " + three.toObjectId().getName()));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
assertFalse(client.getObjectDatabase().has(one.toObjectId()));
@@ -1455,7 +1454,7 @@ public class UploadPackTest {
"shallow " + child1.toObjectId().getName(),
"shallow " + child2.toObjectId().getName()));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
@@ -1899,7 +1898,7 @@ public class UploadPackTest {
hasItems(
one.toObjectId().getName() + " refs/heads/one",
two.toObjectId().getName() + " refs/heads/two"));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
@@ -1955,7 +1954,7 @@ public class UploadPackTest {
assertThat(
pckIn.readString(),
is(one.toObjectId().getName() + " refs/heads/one"));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
@@ -1987,7 +1986,7 @@ public class UploadPackTest {
assertThat(
pckIn.readString(),
is(one.toObjectId().getName() + " refs/heads/one"));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
// ... but the client does not need the object itself.
assertThat(pckIn.readString(), is("packfile"));
@@ -2015,10 +2014,10 @@ public class UploadPackTest {
// shallow-info appears first, then wanted-refs.
assertThat(pckIn.readString(), is("shallow-info"));
assertThat(pckIn.readString(), is("shallow " + child.toObjectId().getName()));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("wanted-refs"));
assertThat(pckIn.readString(), is(child.toObjectId().getName() + " refs/heads/branch1"));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
assertTrue(client.getObjectDatabase().has(child.toObjectId()));
@@ -2050,11 +2049,11 @@ public class UploadPackTest {
is("shallow " + one.toObjectId().getName()));
assertThat(pckIn.readString(),
is("unshallow " + two.toObjectId().getName()));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("wanted-refs"));
assertThat(pckIn.readString(),
is(three.toObjectId().getName() + " refs/heads/three"));
- assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
+ assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java
index 20a5d9da72..e8724b72db 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackConnection.java
@@ -201,7 +201,7 @@ abstract class BasePackConnection extends BaseConnection {
throw noRepository();
throw eof;
}
- if (line == PacketLineIn.END)
+ if (PacketLineIn.isEnd(line))
break;
if (line.startsWith("ERR ")) { //$NON-NLS-1$
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 1741db97fe..e402de0158 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
@@ -1282,7 +1282,7 @@ public abstract class BaseReceivePack {
return;
throw eof;
}
- if (line == PacketLineIn.END) {
+ if (PacketLineIn.isEnd(line)) {
break;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV0Parser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV0Parser.java
index 396327aab0..428a45c09d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV0Parser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV0Parser.java
@@ -99,7 +99,7 @@ final class ProtocolV0Parser {
throw eof;
}
- if (line == PacketLineIn.END) {
+ if (PacketLineIn.isEnd(line)) {
break;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java
index cb04ff69a9..2c7beedc62 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ProtocolV2Parser.java
@@ -92,7 +92,7 @@ final class ProtocolV2Parser {
String agentPrefix = OPTION_AGENT + '=';
String line = pckIn.readString();
- while (line != PacketLineIn.DELIM && line != PacketLineIn.END) {
+ while (!PacketLineIn.isDelimiter(line) && !PacketLineIn.isEnd(line)) {
if (line.startsWith(serverOptionPrefix)) {
serverOptionConsumer
.accept(line.substring(serverOptionPrefix.length()));
@@ -133,11 +133,11 @@ final class ProtocolV2Parser {
serverOption -> reqBuilder.addServerOption(serverOption),
agent -> reqBuilder.setAgent(agent));
- if (line == PacketLineIn.END) {
+ if (PacketLineIn.isEnd(line)) {
return reqBuilder.build();
}
- if (line != PacketLineIn.DELIM) {
+ if (!PacketLineIn.isDelimiter(line)) {
throw new PackProtocolException(
MessageFormat.format(JGitText.get().unexpectedPacketLine,
line));
@@ -244,11 +244,11 @@ final class ProtocolV2Parser {
serverOption -> builder.addServerOption(serverOption),
agent -> builder.setAgent(agent));
- if (line == PacketLineIn.END) {
+ if (PacketLineIn.isEnd(line)) {
return builder.build();
}
- if (line != PacketLineIn.DELIM) {
+ if (!PacketLineIn.isDelimiter(line)) {
throw new PackProtocolException(MessageFormat
.format(JGitText.get().unexpectedPacketLine, line));
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
index 4652c3fda8..d6adf1e0d8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java
@@ -348,7 +348,7 @@ public class ReceivePack extends BaseReceivePack {
pushOptions = new ArrayList<>(4);
for (;;) {
String option = in.readString();
- if (option == PacketLineIn.END) {
+ if (PacketLineIn.isEnd(option)) {
break;
}
pushOptions.add(option);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
index b752a65275..42aa80ea48 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
@@ -902,7 +902,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
JGitText.get().expectedGot, exp, act));
}
- while (pckIn.readString() != PacketLineIn.END) {
+ while (!PacketLineIn.isEnd(pckIn.readString())) {
// for now, ignore the remaining header lines
}
}
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 6217d2a0e9..9278f42adf 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -1229,7 +1229,7 @@ public class UploadPack {
/* EOF when awaiting command is fine */
return true;
}
- if (command == PacketLineIn.END) {
+ if (PacketLineIn.isEnd(command)) {
// A blank request is valid according
// to the protocol; do nothing in this
// case.
@@ -1600,7 +1600,7 @@ public class UploadPack {
throw eof;
}
- if (line == PacketLineIn.END) {
+ if (PacketLineIn.isEnd(line)) {
last = processHaveLines(peerHas, last, pckOut);
if (commonBase.isEmpty() || multiAck != MultiAck.OFF)
pckOut.writeString("NAK\n"); //$NON-NLS-1$