summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2021-02-09 02:42:29 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2021-02-15 16:45:58 +0100
commitf17f8e8ba9cc5bed87ef5637b7ba4bed20b761b5 (patch)
treeed12be515101f214f1d2e2a12e7b6f9000fa6162 /org.eclipse.jgit/src
parent5b528474f590a2abfc6fdc8300e6acfa3d81d355 (diff)
downloadjgit-f17f8e8ba9cc5bed87ef5637b7ba4bed20b761b5.tar.gz
jgit-f17f8e8ba9cc5bed87ef5637b7ba4bed20b761b5.zip
GitHook: use default charset for output and error streams
External scripts most probably expect the default charset. Change-Id: I318a5e1d9f536a95e70c06ffb5b6f408cd40f73a Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java b/org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java
index 49e145088d..e19ebcc37f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/hooks/GitHook.java
@@ -9,11 +9,10 @@
*/
package org.eclipse.jgit.hooks;
-import static java.nio.charset.StandardCharsets.UTF_8;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.nio.charset.Charset;
import java.util.concurrent.Callable;
import org.eclipse.jgit.api.errors.AbortedByHookException;
@@ -155,8 +154,10 @@ abstract class GitHook<T> implements Callable<T> {
*
* @throws org.eclipse.jgit.api.errors.AbortedByHookException
* If the underlying hook script exited with non-zero.
+ * @throws IOException
+ * if an IO error occurred
*/
- protected void doRun() throws AbortedByHookException {
+ protected void doRun() throws AbortedByHookException, IOException {
final ByteArrayOutputStream errorByteArray = new ByteArrayOutputStream();
final TeeOutputStream stderrStream = new TeeOutputStream(errorByteArray,
getErrorStream());
@@ -170,7 +171,8 @@ abstract class GitHook<T> implements Callable<T> {
getStdinArgs());
if (result.isExecutedWithError()) {
throw new AbortedByHookException(
- new String(errorByteArray.toByteArray(), UTF_8),
+ new String(errorByteArray.toByteArray(),
+ Charset.defaultCharset().name()),
getHookName(), result.getExitCode());
}
}