From 94812ef1e97d8bcd93d66fbbb68c8e02ae43b845 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Tue, 28 Jul 2015 10:53:07 -0700 Subject: [PATCH] PushCertificate: Omit null pushee from text representation Change-Id: Ie9546f2e0e9ee62e0a3c919572153b6076355195 --- .../eclipse/jgit/transport/PushCertificateParserTest.java | 1 + .../src/org/eclipse/jgit/transport/PushCertificate.java | 8 +++++--- 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()) -- 2.39.5