|
|
@ -44,6 +44,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.eclipse.jgit.pgm; |
|
|
|
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_HEADS; |
|
|
|
import static org.eclipse.jgit.lib.Constants.R_REMOTES; |
|
|
|
import static org.eclipse.jgit.lib.Constants.R_REMOTES; |
|
|
|
import static org.eclipse.jgit.lib.Constants.R_TAGS; |
|
|
|
import static org.eclipse.jgit.lib.Constants.R_TAGS; |
|
|
@ -56,6 +57,7 @@ import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.io.OutputStreamWriter; |
|
|
|
import java.io.OutputStreamWriter; |
|
|
|
|
|
|
|
import java.nio.charset.Charset; |
|
|
|
import java.text.MessageFormat; |
|
|
|
import java.text.MessageFormat; |
|
|
|
import java.util.ResourceBundle; |
|
|
|
import java.util.ResourceBundle; |
|
|
|
|
|
|
|
|
|
|
@ -177,33 +179,31 @@ public abstract class TextBuiltin { |
|
|
|
* {@code repository} is null. |
|
|
|
* {@code repository} is null. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void init(Repository repository, String gitDir) { |
|
|
|
protected void init(Repository repository, String gitDir) { |
|
|
|
try { |
|
|
|
Charset charset = UTF_8; |
|
|
|
final String outputEncoding = repository != null ? repository |
|
|
|
if (repository != null) { |
|
|
|
.getConfig().getString("i18n", null, "logOutputEncoding") : null; //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
String logOutputEncoding = repository.getConfig().getString("i18n", //$NON-NLS-1$
|
|
|
|
if (ins == null) |
|
|
|
null, |
|
|
|
ins = new FileInputStream(FileDescriptor.in); |
|
|
|
"logOutputEncoding");//$NON-NLS-1$
|
|
|
|
if (outs == null) |
|
|
|
if (logOutputEncoding != null) { |
|
|
|
outs = new FileOutputStream(FileDescriptor.out); |
|
|
|
try { |
|
|
|
if (errs == null) |
|
|
|
charset = Charset.forName(logOutputEncoding); |
|
|
|
errs = new FileOutputStream(FileDescriptor.err); |
|
|
|
} catch (IllegalArgumentException e) { |
|
|
|
BufferedWriter outbufw; |
|
|
|
throw die(CLIText.get().cannotCreateOutputStream); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ins == null) |
|
|
|
|
|
|
|
ins = new FileInputStream(FileDescriptor.in); |
|
|
|
|
|
|
|
if (outs == null) |
|
|
|
|
|
|
|
outs = new FileOutputStream(FileDescriptor.out); |
|
|
|
|
|
|
|
if (errs == null) |
|
|
|
|
|
|
|
errs = new FileOutputStream(FileDescriptor.err); |
|
|
|
|
|
|
|
outw = new ThrowingPrintWriter(new BufferedWriter( |
|
|
|
|
|
|
|
new OutputStreamWriter(outs, charset))); |
|
|
|
|
|
|
|
errw = new ThrowingPrintWriter(new BufferedWriter( |
|
|
|
|
|
|
|
new OutputStreamWriter(errs, charset))); |
|
|
|
|
|
|
|
|
|
|
|
if (repository != null && repository.getDirectory() != null) { |
|
|
|
if (repository != null && repository.getDirectory() != null) { |
|
|
|
db = repository; |
|
|
|
db = repository; |
|
|
|
gitdir = repository.getDirectory().getAbsolutePath(); |
|
|
|
gitdir = repository.getDirectory().getAbsolutePath(); |
|
|
|