|
|
|
@ -172,29 +172,40 @@ public abstract class TextBuiltin {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Initialize the command to work with a repository. |
|
|
|
|
* Get the log output encoding specified in the repository's |
|
|
|
|
* {@code i18n.logOutputEncoding} configuration. |
|
|
|
|
* |
|
|
|
|
* @param repository |
|
|
|
|
* the opened repository that the command should work on. |
|
|
|
|
* @param gitDir |
|
|
|
|
* value of the {@code --git-dir} command line option, if |
|
|
|
|
* {@code repository} is null. |
|
|
|
|
* the repository. |
|
|
|
|
* @return Charset corresponding to {@code i18n.logOutputEncoding}, or |
|
|
|
|
* {@code UTF_8}. |
|
|
|
|
*/ |
|
|
|
|
protected void init(Repository repository, String gitDir) { |
|
|
|
|
Charset charset = UTF_8; |
|
|
|
|
private Charset getLogOutputEncodingCharset(Repository repository) { |
|
|
|
|
if (repository != null) { |
|
|
|
|
String logOutputEncoding = repository.getConfig().getString( |
|
|
|
|
CONFIG_SECTION_I18N, |
|
|
|
|
null, |
|
|
|
|
CONFIG_KEY_LOG_OUTPUT_ENCODING); |
|
|
|
|
CONFIG_SECTION_I18N, null, CONFIG_KEY_LOG_OUTPUT_ENCODING); |
|
|
|
|
if (logOutputEncoding != null) { |
|
|
|
|
try { |
|
|
|
|
charset = Charset.forName(logOutputEncoding); |
|
|
|
|
return Charset.forName(logOutputEncoding); |
|
|
|
|
} catch (IllegalArgumentException e) { |
|
|
|
|
throw die(CLIText.get().cannotCreateOutputStream); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return UTF_8; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Initialize the command to work with a repository. |
|
|
|
|
* |
|
|
|
|
* @param repository |
|
|
|
|
* the opened repository that the command should work on. |
|
|
|
|
* @param gitDir |
|
|
|
|
* value of the {@code --git-dir} command line option, if |
|
|
|
|
* {@code repository} is null. |
|
|
|
|
*/ |
|
|
|
|
protected void init(Repository repository, String gitDir) { |
|
|
|
|
Charset charset = getLogOutputEncodingCharset(repository); |
|
|
|
|
|
|
|
|
|
if (ins == null) |
|
|
|
|
ins = new FileInputStream(FileDescriptor.in); |
|
|
|
|