Avoid double-colon in InvalidObjectIdException description
The invalidId message in JGitText and the asAscii bad id both contain a colon, so the resulting message would say Invalid id: : a78987c98798ufa Fix it by keeping the colon in the translated message and not adding another colon programmatically. Noticed by code inspection. Change-Id: I13972eebde27a4128828e6c64517666f0ba6288b Signed-off-by: Jonathan Nieder <jrn@google.com>
This commit is contained in:
parent
3c33d094a1
commit
0c7ad12c76
|
@ -325,6 +325,7 @@ invalidEncryption=Invalid encryption
|
||||||
invalidGitdirRef = Invalid .git reference in file ''{0}''
|
invalidGitdirRef = Invalid .git reference in file ''{0}''
|
||||||
invalidGitType=invalid git type: {0}
|
invalidGitType=invalid git type: {0}
|
||||||
invalidId=Invalid id: {0}
|
invalidId=Invalid id: {0}
|
||||||
|
invalidId0=Invalid id
|
||||||
invalidIdLength=Invalid id length {0}; should be {1}
|
invalidIdLength=Invalid id length {0}; should be {1}
|
||||||
invalidIgnoreParamSubmodule=Found invalid ignore param for submodule {0}.
|
invalidIgnoreParamSubmodule=Found invalid ignore param for submodule {0}.
|
||||||
invalidIntegerValue=Invalid integer value: {0}.{1}={2}
|
invalidIntegerValue=Invalid integer value: {0}.{1}={2}
|
||||||
|
|
|
@ -45,7 +45,8 @@
|
||||||
|
|
||||||
package org.eclipse.jgit.errors;
|
package org.eclipse.jgit.errors;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import org.eclipse.jgit.internal.JGitText;
|
import org.eclipse.jgit.internal.JGitText;
|
||||||
|
@ -64,16 +65,16 @@ public class InvalidObjectIdException extends IllegalArgumentException {
|
||||||
* @param length of the sequence of invalid bytes.
|
* @param length of the sequence of invalid bytes.
|
||||||
*/
|
*/
|
||||||
public InvalidObjectIdException(byte[] bytes, int offset, int length) {
|
public InvalidObjectIdException(byte[] bytes, int offset, int length) {
|
||||||
super(MessageFormat.format(JGitText.get().invalidId, asAscii(bytes, offset, length)));
|
super(msg(bytes, offset, length));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String asAscii(byte[] bytes, int offset, int length) {
|
private static String msg(byte[] bytes, int offset, int length) {
|
||||||
try {
|
try {
|
||||||
return ": " + new String(bytes, offset, length, "US-ASCII"); //$NON-NLS-1$ //$NON-NLS-2$
|
return MessageFormat.format(
|
||||||
} catch (UnsupportedEncodingException e2) {
|
JGitText.get().invalidId,
|
||||||
return ""; //$NON-NLS-1$
|
new String(bytes, offset, length, US_ASCII));
|
||||||
} catch (StringIndexOutOfBoundsException e2) {
|
} catch (StringIndexOutOfBoundsException e) {
|
||||||
return ""; //$NON-NLS-1$
|
return JGitText.get().invalidId0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,6 +384,7 @@ public static JGitText get() {
|
||||||
/***/ public String invalidGitdirRef;
|
/***/ public String invalidGitdirRef;
|
||||||
/***/ public String invalidGitType;
|
/***/ public String invalidGitType;
|
||||||
/***/ public String invalidId;
|
/***/ public String invalidId;
|
||||||
|
/***/ public String invalidId0;
|
||||||
/***/ public String invalidIdLength;
|
/***/ public String invalidIdLength;
|
||||||
/***/ public String invalidIgnoreParamSubmodule;
|
/***/ public String invalidIgnoreParamSubmodule;
|
||||||
/***/ public String invalidIntegerValue;
|
/***/ public String invalidIntegerValue;
|
||||||
|
|
Loading…
Reference in New Issue