Fix non-externalized String warnings

- suppress warning for non-translatable texts
- externalize error messages

Change-Id: Ieba42219b2c0b51a288f5a60438a6cc4f9dfe641
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2018-04-25 01:05:13 +02:00
parent ce7ac03c2f
commit e341ec0afe
5 changed files with 58 additions and 46 deletions

View File

@ -708,6 +708,7 @@ unexpectedEndOfInput=Unexpected end of input
unexpectedEofInPack=Unexpected EOF in partially created pack unexpectedEofInPack=Unexpected EOF in partially created pack
unexpectedHunkTrailer=Unexpected hunk trailer unexpectedHunkTrailer=Unexpected hunk trailer
unexpectedOddResult=odd: {0} + {1} - {2} unexpectedOddResult=odd: {0} + {1} - {2}
unexpectedPacketLine=unexpected {0}
unexpectedRefReport={0}: unexpected ref report: {1} unexpectedRefReport={0}: unexpected ref report: {1}
unexpectedReportLine=unexpected report line: {0} unexpectedReportLine=unexpected report line: {0}
unexpectedReportLine2={0} unexpected report line: {1} unexpectedReportLine2={0} unexpected report line: {1}
@ -722,6 +723,7 @@ unknownObjectType=Unknown object type {0}.
unknownObjectType2=unknown unknownObjectType2=unknown
unknownRepositoryFormat=Unknown repository format unknownRepositoryFormat=Unknown repository format
unknownRepositoryFormat2=Unknown repository format "{0}"; expected "0". unknownRepositoryFormat2=Unknown repository format "{0}"; expected "0".
unknownTransportCommand=unknown command {0}
unknownZlibError=Unknown zlib error. unknownZlibError=Unknown zlib error.
unmergedPath=Unmerged path: {0} unmergedPath=Unmerged path: {0}
unmergedPaths=Repository contains unmerged paths unmergedPaths=Repository contains unmerged paths

View File

@ -769,6 +769,7 @@ public static JGitText get() {
/***/ public String unexpectedEofInPack; /***/ public String unexpectedEofInPack;
/***/ public String unexpectedHunkTrailer; /***/ public String unexpectedHunkTrailer;
/***/ public String unexpectedOddResult; /***/ public String unexpectedOddResult;
/***/ public String unexpectedPacketLine;
/***/ public String unexpectedRefReport; /***/ public String unexpectedRefReport;
/***/ public String unexpectedReportLine; /***/ public String unexpectedReportLine;
/***/ public String unexpectedReportLine2; /***/ public String unexpectedReportLine2;
@ -783,6 +784,7 @@ public static JGitText get() {
/***/ public String unknownObjectType2; /***/ public String unknownObjectType2;
/***/ public String unknownRepositoryFormat; /***/ public String unknownRepositoryFormat;
/***/ public String unknownRepositoryFormat2; /***/ public String unknownRepositoryFormat2;
/***/ public String unknownTransportCommand;
/***/ public String unknownZlibError; /***/ public String unknownZlibError;
/***/ public String unmergedPath; /***/ public String unmergedPath;
/***/ public String unmergedPaths; /***/ public String unmergedPaths;

View File

@ -297,19 +297,20 @@ public Set<ObjectId> send(Map<String, Ref> refs) throws IOException {
if (useProtocolV2) { if (useProtocolV2) {
String symrefPart = symrefs.containsKey(ref.getName()) String symrefPart = symrefs.containsKey(ref.getName())
? (" symref-target:" + symrefs.get(ref.getName())) ? (" symref-target:" + symrefs.get(ref.getName())) //$NON-NLS-1$
: ""; : ""; //$NON-NLS-1$
String peelPart = ""; String peelPart = ""; //$NON-NLS-1$
if (derefTags) { if (derefTags) {
if (!ref.isPeeled() && repository != null) { if (!ref.isPeeled() && repository != null) {
ref = repository.peel(ref); ref = repository.peel(ref);
} }
ObjectId peeledObjectId = ref.getPeeledObjectId(); ObjectId peeledObjectId = ref.getPeeledObjectId();
if (peeledObjectId != null) { 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; continue;
} }

View File

@ -97,8 +97,8 @@ public enum FsckMode {
* Used in protocol.version. * Used in protocol.version.
*/ */
enum ProtocolVersion { enum ProtocolVersion {
V0("0"), V0("0"), //$NON-NLS-1$
V2("2"); V2("2"); //$NON-NLS-1$
final String name; final String name;
@ -136,26 +136,28 @@ enum ProtocolVersion {
this(db.getConfig()); this(db.getConfig());
} }
@SuppressWarnings("nls")
TransferConfig(final Config rc) { TransferConfig(final Config rc) {
boolean fsck = rc.getBoolean("transfer", "fsckobjects", false); //$NON-NLS-1$ //$NON-NLS-2$ boolean fsck = rc.getBoolean("transfer", "fsckobjects", false);
fetchFsck = rc.getBoolean("fetch", "fsckobjects", fsck); //$NON-NLS-1$ //$NON-NLS-2$ fetchFsck = rc.getBoolean("fetch", "fsckobjects", fsck);
receiveFsck = rc.getBoolean("receive", "fsckobjects", fsck); //$NON-NLS-1$ //$NON-NLS-2$ receiveFsck = rc.getBoolean("receive", "fsckobjects", fsck);
fsckSkipList = rc.getString(FSCK, null, "skipList"); //$NON-NLS-1$ fsckSkipList = rc.getString(FSCK, null, "skipList");
allowInvalidPersonIdent = rc.getBoolean(FSCK, "allowInvalidPersonIdent", false); //$NON-NLS-1$ allowInvalidPersonIdent = rc.getBoolean(FSCK, "allowInvalidPersonIdent",
safeForWindows = rc.getBoolean(FSCK, "safeForWindows", //$NON-NLS-1$ false);
safeForWindows = rc.getBoolean(FSCK, "safeForWindows",
SystemReader.getInstance().isWindows()); SystemReader.getInstance().isWindows());
safeForMacOS = rc.getBoolean(FSCK, "safeForMacOS", //$NON-NLS-1$ safeForMacOS = rc.getBoolean(FSCK, "safeForMacOS",
SystemReader.getInstance().isMacOS()); SystemReader.getInstance().isMacOS());
ignore = EnumSet.noneOf(ObjectChecker.ErrorType.class); ignore = EnumSet.noneOf(ObjectChecker.ErrorType.class);
EnumSet<ObjectChecker.ErrorType> set = EnumSet EnumSet<ObjectChecker.ErrorType> set = EnumSet
.noneOf(ObjectChecker.ErrorType.class); .noneOf(ObjectChecker.ErrorType.class);
for (String key : rc.getNames(FSCK)) { for (String key : rc.getNames(FSCK)) {
if (equalsIgnoreCase(key, "skipList") //$NON-NLS-1$ if (equalsIgnoreCase(key, "skipList")
|| equalsIgnoreCase(key, "allowLeadingZeroFileMode") //$NON-NLS-1$ || equalsIgnoreCase(key, "allowLeadingZeroFileMode")
|| equalsIgnoreCase(key, "allowInvalidPersonIdent") //$NON-NLS-1$ || equalsIgnoreCase(key, "allowInvalidPersonIdent")
|| equalsIgnoreCase(key, "safeForWindows") //$NON-NLS-1$ || equalsIgnoreCase(key, "safeForWindows")
|| equalsIgnoreCase(key, "safeForMacOS")) { //$NON-NLS-1$ || equalsIgnoreCase(key, "safeForMacOS")) {
continue; continue;
} }
@ -174,18 +176,18 @@ enum ProtocolVersion {
} }
} }
if (!set.contains(ObjectChecker.ErrorType.ZERO_PADDED_FILEMODE) 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); ignore.add(ObjectChecker.ErrorType.ZERO_PADDED_FILEMODE);
} }
allowTipSha1InWant = rc.getBoolean( allowTipSha1InWant = rc.getBoolean(
"uploadpack", "allowtipsha1inwant", false); //$NON-NLS-1$ //$NON-NLS-2$ "uploadpack", "allowtipsha1inwant", false);
allowReachableSha1InWant = rc.getBoolean( allowReachableSha1InWant = rc.getBoolean(
"uploadpack", "allowreachablesha1inwant", false); //$NON-NLS-1$ //$NON-NLS-2$ "uploadpack", "allowreachablesha1inwant", false);
allowFilter = rc.getBoolean( allowFilter = rc.getBoolean(
"uploadpack", "allowfilter", false); //$NON-NLS-1$ //$NON-NLS-2$ "uploadpack", "allowfilter", false);
protocolVersion = ProtocolVersion.parse(rc.getString("protocol", null, "version")); 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");
} }
/** /**

View File

@ -44,8 +44,8 @@
package org.eclipse.jgit.transport; package org.eclipse.jgit.transport;
import static org.eclipse.jgit.lib.RefDatabase.ALL; 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_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_AGENT;
import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_ALLOW_REACHABLE_SHA1_IN_WANT; 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; import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_ALLOW_TIP_SHA1_IN_WANT;
@ -75,6 +75,7 @@
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException; 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 // UploadPack sends these lines as the first response to a client that
// supports protocol version 2. // supports protocol version 2.
private static final String[] v2CapabilityAdvertisement = { private static final String[] v2CapabilityAdvertisement = {
"version 2", "version 2", //$NON-NLS-1$
COMMAND_LS_REFS, COMMAND_LS_REFS,
COMMAND_FETCH COMMAND_FETCH
}; };
@ -688,7 +689,7 @@ public boolean isSideBand() throws RequestNotYetReadException {
* @since 5.0 * @since 5.0
*/ */
public void setExtraParameters(Collection<String> params) { 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() { private boolean useProtocolV2() {
@ -883,18 +884,20 @@ private void lsRefsV2() throws IOException {
// line is DELIM if there are arguments or END if not. // line is DELIM if there are arguments or END if not.
if (line == PacketLineIn.DELIM) { if (line == PacketLineIn.DELIM) {
while ((line = pckIn.readString()) != PacketLineIn.END) { while ((line = pckIn.readString()) != PacketLineIn.END) {
if (line.equals("peel")) { if (line.equals("peel")) { //$NON-NLS-1$
adv.setDerefTags(true); adv.setDerefTags(true);
} else if (line.equals("symrefs")) { } else if (line.equals("symrefs")) { //$NON-NLS-1$
needToFindSymrefs = true; needToFindSymrefs = true;
} else if (line.startsWith("ref-prefix ")) { } else if (line.startsWith("ref-prefix ")) { //$NON-NLS-1$
refPrefixes.add(line.substring("ref-prefix ".length())); refPrefixes.add(line.substring("ref-prefix ".length())); //$NON-NLS-1$
} else { } else {
throw new PackProtocolException("unexpected " + line); throw new PackProtocolException(MessageFormat
.format(JGitText.get().unexpectedPacketLine, line));
} }
} }
} else if (line != PacketLineIn.END) { } else if (line != PacketLineIn.END) {
throw new PackProtocolException("unexpected " + line); throw new PackProtocolException(MessageFormat
.format(JGitText.get().unexpectedPacketLine, line));
} }
rawOut.stopBuffering(); rawOut.stopBuffering();
@ -944,15 +947,16 @@ private void fetchV2() throws IOException {
// Currently, we do not support any capabilities, so the next // Currently, we do not support any capabilities, so the next
// line is DELIM. // line is DELIM.
if ((line = pckIn.readString()) != PacketLineIn.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) { while ((line = pckIn.readString()) != PacketLineIn.END) {
if (line.startsWith("want ")) { if (line.startsWith("want ")) { //$NON-NLS-1$
wantIds.add(ObjectId.fromString(line.substring(5))); 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))); peerHas.add(ObjectId.fromString(line.substring(5)));
} else if (line.equals("done")) { } else if (line.equals("done")) { //$NON-NLS-1$
doneReceived = true; doneReceived = true;
} else if (line.equals(OPTION_THIN_PACK)) { } else if (line.equals(OPTION_THIN_PACK)) {
options.add(OPTION_THIN_PACK); options.add(OPTION_THIN_PACK);
@ -967,24 +971,24 @@ private void fetchV2() throws IOException {
if (doneReceived) { if (doneReceived) {
processHaveLines(peerHas, ObjectId.zeroId(), new PacketLineOut(NullOutputStream.INSTANCE)); processHaveLines(peerHas, ObjectId.zeroId(), new PacketLineOut(NullOutputStream.INSTANCE));
} else { } else {
pckOut.writeString("acknowledgments\n"); pckOut.writeString("acknowledgments\n"); //$NON-NLS-1$
for (ObjectId id : peerHas) { for (ObjectId id : peerHas) {
if (walk.getObjectReader().has(id)) { 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)); processHaveLines(peerHas, ObjectId.zeroId(), new PacketLineOut(NullOutputStream.INSTANCE));
if (okToGiveUp()) { if (okToGiveUp()) {
pckOut.writeString("ready\n"); pckOut.writeString("ready\n"); //$NON-NLS-1$
} else if (commonBase.isEmpty()) { } else if (commonBase.isEmpty()) {
pckOut.writeString("NAK\n"); pckOut.writeString("NAK\n"); //$NON-NLS-1$
} }
sectionSent = true; sectionSent = true;
} }
if (doneReceived || okToGiveUp()) { if (doneReceived || okToGiveUp()) {
if (sectionSent) if (sectionSent)
pckOut.writeDelim(); pckOut.writeDelim();
pckOut.writeString("packfile\n"); pckOut.writeString("packfile\n"); //$NON-NLS-1$
sendPack(new PackStatistics.Accumulator()); sendPack(new PackStatistics.Accumulator());
} }
pckOut.end(); pckOut.end();
@ -1008,15 +1012,16 @@ private boolean serveOneCommandV2() throws IOException {
// case. // case.
return true; return true;
} }
if (command.equals("command=" + COMMAND_LS_REFS)) { if (command.equals("command=" + COMMAND_LS_REFS)) { //$NON-NLS-1$
lsRefsV2(); lsRefsV2();
return false; return false;
} }
if (command.equals("command=" + COMMAND_FETCH)) { if (command.equals("command=" + COMMAND_FETCH)) { //$NON-NLS-1$
fetchV2(); fetchV2();
return false; return false;
} }
throw new PackProtocolException("unknown command " + command); throw new PackProtocolException(MessageFormat
.format(JGitText.get().unknownTransportCommand, command));
} }
private void serviceV2() throws IOException { private void serviceV2() throws IOException {
@ -1026,7 +1031,7 @@ private void serviceV2() throws IOException {
// not, the client is expected to call // not, the client is expected to call
// sendAdvertisedRefs() on its own.) // sendAdvertisedRefs() on its own.)
for (String s : v2CapabilityAdvertisement) { for (String s : v2CapabilityAdvertisement) {
pckOut.writeString(s + "\n"); pckOut.writeString(s + "\n"); //$NON-NLS-1$
} }
pckOut.end(); pckOut.end();