aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2015-07-28 10:53:07 -0700
committerDave Borowitz <dborowitz@google.com>2015-07-28 10:53:07 -0700
commit94812ef1e97d8bcd93d66fbbb68c8e02ae43b845 (patch)
tree77bc494d404a49225171d804ce2670d74170a064
parentffa3d4bdb4714bec320de9ecfacb42463abc276b (diff)
downloadjgit-94812ef1e97d8bcd93d66fbbb68c8e02ae43b845.tar.gz
jgit-94812ef1e97d8bcd93d66fbbb68c8e02ae43b845.zip
PushCertificate: Omit null pushee from text representation
Change-Id: Ie9546f2e0e9ee62e0a3c919572153b6076355195
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java8
2 files changed, 6 insertions, 3 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java
index 644b9017ce..0647167eab 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java
@@ -360,6 +360,7 @@ public class PushCertificateParserTest {
PushCertificate cert = parser.build();
assertEquals("0.1", cert.getVersion());
assertNull(cert.getPushee());
+ assertFalse(cert.toText().contains(PushCertificateParser.PUSHEE));
}
private static String concatPacketLines(String input, int begin, int end)
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java
index dbdf93b964..e450345b56 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java
@@ -219,9 +219,11 @@ public class PushCertificate {
StringBuilder sb = new StringBuilder()
.append(VERSION).append(' ').append(version).append('\n')
.append(PUSHER).append(' ').append(getPusher())
- .append('\n')
- .append(PUSHEE).append(' ').append(pushee).append('\n')
- .append(NONCE).append(' ').append(nonce).append('\n')
+ .append('\n');
+ if (pushee != null) {
+ sb.append(PUSHEE).append(' ').append(pushee).append('\n');
+ }
+ sb.append(NONCE).append(' ').append(nonce).append('\n')
.append('\n');
for (ReceiveCommand cmd : commands) {
sb.append(cmd.getOldId().name())