]> source.dussan.org Git - jgit.git/commitdiff
Fix "remote: Counting objects: ..." formatting 03/63403/2
authorShawn Pearce <sop@google.com>
Fri, 1 Jan 2016 00:12:51 +0000 (16:12 -0800)
committerShawn Pearce <sop@google.com>
Fri, 1 Jan 2016 01:37:16 +0000 (17:37 -0800)
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

org.eclipse.jgit/src/org/eclipse/jgit/transport/SideBandInputStream.java

index cf388e2718e3cbc188c1b4bd5fe3498192128423..fe9f2a315523e1e08c6b616b41e3db6d4bd48738 100644 (file)
@@ -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 {