TextBuiltin: Default to UTF-8 when i18n.logOutputEncoding is not set
Change-Id: I69d82086c052b7ba601e0daab133573ec37c25cf Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
This commit is contained in:
parent
74789e7786
commit
4316e1c3a9
|
@ -44,6 +44,7 @@
|
|||
|
||||
package org.eclipse.jgit.pgm;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.eclipse.jgit.lib.Constants.R_HEADS;
|
||||
import static org.eclipse.jgit.lib.Constants.R_REMOTES;
|
||||
import static org.eclipse.jgit.lib.Constants.R_TAGS;
|
||||
|
@ -56,6 +57,7 @@
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
|
@ -177,32 +179,30 @@ public void initRaw(final Repository repository, final String gitDir,
|
|||
* {@code repository} is null.
|
||||
*/
|
||||
protected void init(Repository repository, String gitDir) {
|
||||
Charset charset = UTF_8;
|
||||
if (repository != null) {
|
||||
String logOutputEncoding = repository.getConfig().getString("i18n", //$NON-NLS-1$
|
||||
null,
|
||||
"logOutputEncoding");//$NON-NLS-1$
|
||||
if (logOutputEncoding != null) {
|
||||
try {
|
||||
final String outputEncoding = repository != null ? repository
|
||||
.getConfig().getString("i18n", null, "logOutputEncoding") : null; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
charset = Charset.forName(logOutputEncoding);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw die(CLIText.get().cannotCreateOutputStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ins == null)
|
||||
ins = new FileInputStream(FileDescriptor.in);
|
||||
if (outs == null)
|
||||
outs = new FileOutputStream(FileDescriptor.out);
|
||||
if (errs == null)
|
||||
errs = new FileOutputStream(FileDescriptor.err);
|
||||
BufferedWriter outbufw;
|
||||
if (outputEncoding != null)
|
||||
outbufw = new BufferedWriter(new OutputStreamWriter(outs,
|
||||
outputEncoding));
|
||||
else
|
||||
outbufw = new BufferedWriter(new OutputStreamWriter(outs));
|
||||
outw = new ThrowingPrintWriter(outbufw);
|
||||
BufferedWriter errbufw;
|
||||
if (outputEncoding != null)
|
||||
errbufw = new BufferedWriter(new OutputStreamWriter(errs,
|
||||
outputEncoding));
|
||||
else
|
||||
errbufw = new BufferedWriter(new OutputStreamWriter(errs));
|
||||
errw = new ThrowingPrintWriter(errbufw);
|
||||
} catch (IOException e) {
|
||||
throw die(CLIText.get().cannotCreateOutputStream);
|
||||
}
|
||||
outw = new ThrowingPrintWriter(new BufferedWriter(
|
||||
new OutputStreamWriter(outs, charset)));
|
||||
errw = new ThrowingPrintWriter(new BufferedWriter(
|
||||
new OutputStreamWriter(errs, charset)));
|
||||
|
||||
if (repository != null && repository.getDirectory() != null) {
|
||||
db = repository;
|
||||
|
|
Loading…
Reference in New Issue