From 09500165a8592386c92c1f10a36bfd4fc4666a11 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Thu, 31 Dec 2015 16:12:51 -0800 Subject: [PATCH] Fix "remote: Counting objects: ..." formatting Trailing whitespace is usually removed in properties files so JGitText did not supply a space between : and the remote message. Ensure the space exists at runtime by reading the localized string and appending a space if it is missing. Messages should be dynamically fetched and not held in a static class variable, as they can be changed using thread locals. Change-Id: If6a3707d64094253b1a5304fbfafcf195db7497a --- .../jgit/transport/SideBandInputStream.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java index cf388e2718..fe9f2a3155 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java @@ -78,12 +78,8 @@ import org.eclipse.jgit.util.RawParseUtils; * @see SideBandOutputStream */ class SideBandInputStream extends InputStream { - private static final String PFX_REMOTE = JGitText.get().prefixRemote; - static final int CH_DATA = 1; - static final int CH_PROGRESS = 2; - static final int CH_ERROR = 3; private static Pattern P_UNBOUNDED = Pattern @@ -174,7 +170,7 @@ class SideBandInputStream extends InputStream { continue; case CH_ERROR: eof = true; - throw new TransportException(PFX_REMOTE + readString(available)); + throw new TransportException(remote(readString(available))); default: throw new PackProtocolException( MessageFormat.format(JGitText.get().invalidChannel, @@ -241,7 +237,18 @@ class SideBandInputStream extends InputStream { } private void beginTask(final int totalWorkUnits) { - monitor.beginTask(PFX_REMOTE + currentTask, totalWorkUnits); + monitor.beginTask(remote(currentTask), totalWorkUnits); + } + + private static String remote(String msg) { + String prefix = JGitText.get().prefixRemote; + StringBuilder r = new StringBuilder(prefix.length() + msg.length() + 1); + r.append(prefix); + if (prefix.length() > 0 && prefix.charAt(prefix.length() - 1) != ' ') { + r.append(' '); + } + r.append(msg); + return r.toString(); } private String readString(final int len) throws IOException { -- 2.39.5