]> source.dussan.org Git - jgit.git/commitdiff
Fix non-externalized String warnings 96/121696/1
authorMatthias Sohn <matthias.sohn@sap.com>
Tue, 24 Apr 2018 23:05:13 +0000 (01:05 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 24 Apr 2018 23:05:13 +0000 (01:05 +0200)
- suppress warning for non-translatable texts
- externalize error messages

Change-Id: Ieba42219b2c0b51a288f5a60438a6cc4f9dfe641
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/RefAdvertiser.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

index 28c414dcb2e370b5b48716a439f83fd0bb0bfeb6..01946e064aa8853107b6b45d66341ca8944d2fd5 100644 (file)
@@ -708,6 +708,7 @@ unexpectedEndOfInput=Unexpected end of input
 unexpectedEofInPack=Unexpected EOF in partially created pack
 unexpectedHunkTrailer=Unexpected hunk trailer
 unexpectedOddResult=odd: {0} + {1} - {2}
+unexpectedPacketLine=unexpected {0}
 unexpectedRefReport={0}: unexpected ref report: {1}
 unexpectedReportLine=unexpected report line: {0}
 unexpectedReportLine2={0} unexpected report line: {1}
@@ -722,6 +723,7 @@ unknownObjectType=Unknown object type {0}.
 unknownObjectType2=unknown
 unknownRepositoryFormat=Unknown repository format
 unknownRepositoryFormat2=Unknown repository format "{0}"; expected "0".
+unknownTransportCommand=unknown command {0}
 unknownZlibError=Unknown zlib error.
 unmergedPath=Unmerged path: {0}
 unmergedPaths=Repository contains unmerged paths
index 3c02302d227aa96da840e266888f85bbfdd7968d..6799576c78de1c2dc72e0a107ba325fdefede777 100644 (file)
@@ -769,6 +769,7 @@ public class JGitText extends TranslationBundle {
        /***/ public String unexpectedEofInPack;
        /***/ public String unexpectedHunkTrailer;
        /***/ public String unexpectedOddResult;
+       /***/ public String unexpectedPacketLine;
        /***/ public String unexpectedRefReport;
        /***/ public String unexpectedReportLine;
        /***/ public String unexpectedReportLine2;
@@ -783,6 +784,7 @@ public class JGitText extends TranslationBundle {
        /***/ public String unknownObjectType2;
        /***/ public String unknownRepositoryFormat;
        /***/ public String unknownRepositoryFormat2;
+       /***/ public String unknownTransportCommand;
        /***/ public String unknownZlibError;
        /***/ public String unmergedPath;
        /***/ public String unmergedPaths;
index 60401355a64948a2a345885f1c5a2cb93b219d4c..07d0bfdc0a9b91029ece78b4f200f2094c8d1a43 100644 (file)
@@ -297,19 +297,20 @@ public abstract class RefAdvertiser {
 
                        if (useProtocolV2) {
                                String symrefPart = symrefs.containsKey(ref.getName())
-                                       ? (" symref-target:" + symrefs.get(ref.getName()))
-                                       : "";
-                               String peelPart = "";
+                                               ? (" symref-target:" + symrefs.get(ref.getName())) //$NON-NLS-1$
+                                               : ""; //$NON-NLS-1$
+                               String peelPart = ""; //$NON-NLS-1$
                                if (derefTags) {
                                        if (!ref.isPeeled() && repository != null) {
                                                ref = repository.peel(ref);
                                        }
                                        ObjectId peeledObjectId = ref.getPeeledObjectId();
                                        if (peeledObjectId != null) {
-                                               peelPart = " peeled:" + peeledObjectId.getName();
+                                               peelPart = " peeled:" + peeledObjectId.getName(); //$NON-NLS-1$
                                        }
                                }
-                               writeOne(objectId.getName() + " " + ref.getName() + symrefPart + peelPart + "\n");
+                               writeOne(objectId.getName() + " " + ref.getName() + symrefPart //$NON-NLS-1$
+                                               + peelPart + "\n"); //$NON-NLS-1$
                                continue;
                        }
 
index 7a7efd6b88427298eecd8d83605e762b32d6b548..21c0a92964ece4c5ca9c6543851209742090e082 100644 (file)
@@ -97,8 +97,8 @@ public class TransferConfig {
         * Used in protocol.version.
         */
        enum ProtocolVersion {
-               V0("0"),
-               V2("2");
+               V0("0"), //$NON-NLS-1$
+               V2("2"); //$NON-NLS-1$
 
                final String name;
 
@@ -136,26 +136,28 @@ public class TransferConfig {
                this(db.getConfig());
        }
 
+       @SuppressWarnings("nls")
        TransferConfig(final Config rc) {
-               boolean fsck = rc.getBoolean("transfer", "fsckobjects", false); //$NON-NLS-1$ //$NON-NLS-2$
-               fetchFsck = rc.getBoolean("fetch", "fsckobjects", fsck); //$NON-NLS-1$ //$NON-NLS-2$
-               receiveFsck = rc.getBoolean("receive", "fsckobjects", fsck); //$NON-NLS-1$ //$NON-NLS-2$
-               fsckSkipList = rc.getString(FSCK, null, "skipList"); //$NON-NLS-1$
-               allowInvalidPersonIdent = rc.getBoolean(FSCK, "allowInvalidPersonIdent", false); //$NON-NLS-1$
-               safeForWindows = rc.getBoolean(FSCK, "safeForWindows", //$NON-NLS-1$
+               boolean fsck = rc.getBoolean("transfer", "fsckobjects", false);
+               fetchFsck = rc.getBoolean("fetch", "fsckobjects", fsck);
+               receiveFsck = rc.getBoolean("receive", "fsckobjects", fsck);
+               fsckSkipList = rc.getString(FSCK, null, "skipList");
+               allowInvalidPersonIdent = rc.getBoolean(FSCK, "allowInvalidPersonIdent",
+                               false);
+               safeForWindows = rc.getBoolean(FSCK, "safeForWindows",
                                                SystemReader.getInstance().isWindows());
-               safeForMacOS = rc.getBoolean(FSCK, "safeForMacOS", //$NON-NLS-1$
+               safeForMacOS = rc.getBoolean(FSCK, "safeForMacOS",
                                                SystemReader.getInstance().isMacOS());
 
                ignore = EnumSet.noneOf(ObjectChecker.ErrorType.class);
                EnumSet<ObjectChecker.ErrorType> set = EnumSet
                                .noneOf(ObjectChecker.ErrorType.class);
                for (String key : rc.getNames(FSCK)) {
-                       if (equalsIgnoreCase(key, "skipList") //$NON-NLS-1$
-                                       || equalsIgnoreCase(key, "allowLeadingZeroFileMode") //$NON-NLS-1$
-                                       || equalsIgnoreCase(key, "allowInvalidPersonIdent") //$NON-NLS-1$
-                                       || equalsIgnoreCase(key, "safeForWindows") //$NON-NLS-1$
-                                       || equalsIgnoreCase(key, "safeForMacOS")) { //$NON-NLS-1$
+                       if (equalsIgnoreCase(key, "skipList")
+                                       || equalsIgnoreCase(key, "allowLeadingZeroFileMode")
+                                       || equalsIgnoreCase(key, "allowInvalidPersonIdent")
+                                       || equalsIgnoreCase(key, "safeForWindows")
+                                       || equalsIgnoreCase(key, "safeForMacOS")) {
                                continue;
                        }
 
@@ -174,18 +176,18 @@ public class TransferConfig {
                        }
                }
                if (!set.contains(ObjectChecker.ErrorType.ZERO_PADDED_FILEMODE)
-                               && rc.getBoolean(FSCK, "allowLeadingZeroFileMode", false)) { //$NON-NLS-1$
+                               && rc.getBoolean(FSCK, "allowLeadingZeroFileMode", false)) {
                        ignore.add(ObjectChecker.ErrorType.ZERO_PADDED_FILEMODE);
                }
 
                allowTipSha1InWant = rc.getBoolean(
-                               "uploadpack", "allowtipsha1inwant", false); //$NON-NLS-1$ //$NON-NLS-2$
+                               "uploadpack", "allowtipsha1inwant", false);
                allowReachableSha1InWant = rc.getBoolean(
-                               "uploadpack", "allowreachablesha1inwant", false); //$NON-NLS-1$ //$NON-NLS-2$
+                               "uploadpack", "allowreachablesha1inwant", false);
                allowFilter = rc.getBoolean(
-                               "uploadpack", "allowfilter", false); //$NON-NLS-1$ //$NON-NLS-2$
+                               "uploadpack", "allowfilter", false);
                protocolVersion = ProtocolVersion.parse(rc.getString("protocol", null, "version"));
-               hideRefs = rc.getStringList("uploadpack", null, "hiderefs"); //$NON-NLS-1$ //$NON-NLS-2$
+               hideRefs = rc.getStringList("uploadpack", null, "hiderefs");
        }
 
        /**
index 5c02ae96587bfd589d41144e9f62ef9e6cbef347..79c35e37e04557926b4735ca81679fd41e4b918d 100644 (file)
@@ -44,8 +44,8 @@
 package org.eclipse.jgit.transport;
 
 import static org.eclipse.jgit.lib.RefDatabase.ALL;
-import static org.eclipse.jgit.transport.GitProtocolConstants.COMMAND_LS_REFS;
 import static org.eclipse.jgit.transport.GitProtocolConstants.COMMAND_FETCH;
+import static org.eclipse.jgit.transport.GitProtocolConstants.COMMAND_LS_REFS;
 import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_AGENT;
 import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_ALLOW_REACHABLE_SHA1_IN_WANT;
 import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_ALLOW_TIP_SHA1_IN_WANT;
@@ -75,6 +75,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+
 import org.eclipse.jgit.errors.CorruptObjectException;
 import org.eclipse.jgit.errors.IncorrectObjectTypeException;
 import org.eclipse.jgit.errors.MissingObjectException;
@@ -119,7 +120,7 @@ public class UploadPack {
        // UploadPack sends these lines as the first response to a client that
        // supports protocol version 2.
        private static final String[] v2CapabilityAdvertisement = {
-               "version 2",
+               "version 2", //$NON-NLS-1$
                COMMAND_LS_REFS,
                COMMAND_FETCH
        };
@@ -688,7 +689,7 @@ public class UploadPack {
         * @since 5.0
         */
        public void setExtraParameters(Collection<String> params) {
-               this.clientRequestedV2 = params.contains("version=2"); // $NON-NLS-1$
+               this.clientRequestedV2 = params.contains("version=2"); //$NON-NLS-1$
        }
 
        private boolean useProtocolV2() {
@@ -883,18 +884,20 @@ public class UploadPack {
                // line is DELIM if there are arguments or END if not.
                if (line == PacketLineIn.DELIM) {
                        while ((line = pckIn.readString()) != PacketLineIn.END) {
-                               if (line.equals("peel")) {
+                               if (line.equals("peel")) { //$NON-NLS-1$
                                        adv.setDerefTags(true);
-                               } else if (line.equals("symrefs")) {
+                               } else if (line.equals("symrefs")) { //$NON-NLS-1$
                                        needToFindSymrefs = true;
-                               } else if (line.startsWith("ref-prefix ")) {
-                                       refPrefixes.add(line.substring("ref-prefix ".length()));
+                               } else if (line.startsWith("ref-prefix ")) { //$NON-NLS-1$
+                                       refPrefixes.add(line.substring("ref-prefix ".length())); //$NON-NLS-1$
                                } else {
-                                       throw new PackProtocolException("unexpected " + line);
+                                       throw new PackProtocolException(MessageFormat
+                                                       .format(JGitText.get().unexpectedPacketLine, line));
                                }
                        }
                } else if (line != PacketLineIn.END) {
-                       throw new PackProtocolException("unexpected " + line);
+                       throw new PackProtocolException(MessageFormat
+                                       .format(JGitText.get().unexpectedPacketLine, line));
                }
                rawOut.stopBuffering();
 
@@ -944,15 +947,16 @@ public class UploadPack {
                // Currently, we do not support any capabilities, so the next
                // line is DELIM.
                if ((line = pckIn.readString()) != PacketLineIn.DELIM) {
-                       throw new PackProtocolException("unexpected " + line);
+                       throw new PackProtocolException(MessageFormat
+                                       .format(JGitText.get().unexpectedPacketLine, line));
                }
 
                while ((line = pckIn.readString()) != PacketLineIn.END) {
-                       if (line.startsWith("want ")) {
+                       if (line.startsWith("want ")) { //$NON-NLS-1$
                                wantIds.add(ObjectId.fromString(line.substring(5)));
-                       } else if (line.startsWith("have ")) {
+                       } else if (line.startsWith("have ")) { //$NON-NLS-1$
                                peerHas.add(ObjectId.fromString(line.substring(5)));
-                       } else if (line.equals("done")) {
+                       } else if (line.equals("done")) { //$NON-NLS-1$
                                doneReceived = true;
                        } else if (line.equals(OPTION_THIN_PACK)) {
                                options.add(OPTION_THIN_PACK);
@@ -967,24 +971,24 @@ public class UploadPack {
                if (doneReceived) {
                        processHaveLines(peerHas, ObjectId.zeroId(), new PacketLineOut(NullOutputStream.INSTANCE));
                } else {
-                       pckOut.writeString("acknowledgments\n");
+                       pckOut.writeString("acknowledgments\n"); //$NON-NLS-1$
                        for (ObjectId id : peerHas) {
                                if (walk.getObjectReader().has(id)) {
-                                       pckOut.writeString("ACK " + id.getName() + "\n");
+                                       pckOut.writeString("ACK " + id.getName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
                                }
                        }
                        processHaveLines(peerHas, ObjectId.zeroId(), new PacketLineOut(NullOutputStream.INSTANCE));
                        if (okToGiveUp()) {
-                               pckOut.writeString("ready\n");
+                               pckOut.writeString("ready\n"); //$NON-NLS-1$
                        } else if (commonBase.isEmpty()) {
-                               pckOut.writeString("NAK\n");
+                               pckOut.writeString("NAK\n"); //$NON-NLS-1$
                        }
                        sectionSent = true;
                }
                if (doneReceived || okToGiveUp()) {
                        if (sectionSent)
                                pckOut.writeDelim();
-                       pckOut.writeString("packfile\n");
+                       pckOut.writeString("packfile\n"); //$NON-NLS-1$
                        sendPack(new PackStatistics.Accumulator());
                }
                pckOut.end();
@@ -1008,15 +1012,16 @@ public class UploadPack {
                        // case.
                        return true;
                }
-               if (command.equals("command=" + COMMAND_LS_REFS)) {
+               if (command.equals("command=" + COMMAND_LS_REFS)) { //$NON-NLS-1$
                        lsRefsV2();
                        return false;
                }
-               if (command.equals("command=" + COMMAND_FETCH)) {
+               if (command.equals("command=" + COMMAND_FETCH)) { //$NON-NLS-1$
                        fetchV2();
                        return false;
                }
-               throw new PackProtocolException("unknown command " + command);
+               throw new PackProtocolException(MessageFormat
+                               .format(JGitText.get().unknownTransportCommand, command));
        }
 
        private void serviceV2() throws IOException {
@@ -1026,7 +1031,7 @@ public class UploadPack {
                        // not, the client is expected to call
                        // sendAdvertisedRefs() on its own.)
                        for (String s : v2CapabilityAdvertisement) {
-                               pckOut.writeString(s + "\n");
+                               pckOut.writeString(s + "\n"); //$NON-NLS-1$
                        }
                        pckOut.end();