]> source.dussan.org Git - jgit.git/commitdiff
Add TemporaryBuffer.toString(int limit) 51/180351/4
authorMatthias Sohn <matthias.sohn@sap.com>
Fri, 7 May 2021 08:50:58 +0000 (10:50 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Sun, 9 May 2021 20:49:15 +0000 (22:49 +0200)
Change-Id: I8603fcdfd0244088b3b217f002a78e7a646ea205
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java

index 671475ed47fd691c01192035cc4bc8ae69734dcc..c904a782dbe60df092729fcec191c19e7a3ca8a4 100644 (file)
@@ -1610,11 +1610,9 @@ public class DirCacheCheckout {
                }
                if (rc != 0) {
                        throw new IOException(new FilterFailedException(rc,
-                                       checkoutMetadata.smudgeFilterCommand,
-                                       path,
+                                       checkoutMetadata.smudgeFilterCommand, path,
                                        result.getStdout().toByteArray(MAX_EXCEPTION_TEXT_SIZE),
-                                       RawParseUtils.decode(result.getStderr()
-                                                       .toByteArray(MAX_EXCEPTION_TEXT_SIZE))));
+                                       result.getStderr().toString(MAX_EXCEPTION_TEXT_SIZE)));
                }
        }
 
index 55b7d6279ace42975addb184a341957c8b425ebc..0b7c0a9e4bc37291103275c65e16d483ece24671 100644 (file)
@@ -502,8 +502,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
                                throw new IOException(new FilterFailedException(rc,
                                                filterCommand, getEntryPathString(),
                                                result.getStdout().toByteArray(MAX_EXCEPTION_TEXT_SIZE),
-                                               RawParseUtils.decode(result.getStderr()
-                                                               .toByteArray(MAX_EXCEPTION_TEXT_SIZE))));
+                                               result.getStderr().toString(MAX_EXCEPTION_TEXT_SIZE)));
                        }
                        return result.getStdout().openInputStreamWithAutoDestroy();
                }
index 562eb05dd9cbf616a53ad78be3a26856c42ad087..fb893a66f02fb5d91ad0b4a08f2e9785f5c19764 100644 (file)
@@ -18,6 +18,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.UncheckedIOException;
 import java.util.ArrayList;
 
 import org.eclipse.jgit.internal.JGitText;
@@ -212,6 +213,24 @@ public abstract class TemporaryBuffer extends OutputStream {
                return out;
        }
 
+       /**
+        * Convert first {@code limit} number of bytes of the buffer content to
+        * String.
+        *
+        * @param limit
+        *            the maximum number of bytes to be converted to String
+        * @return first {@code limit} number of bytes of the buffer content
+        *         converted to String.
+        * @since 5.12
+        */
+       public String toString(int limit) {
+               try {
+                       return RawParseUtils.decode(toByteArray(limit));
+               } catch (IOException e) {
+                       throw new UncheckedIOException(e);
+               }
+       }
+
        /**
         * Convert this buffer's contents into a contiguous byte array. If this size
         * of the buffer exceeds the limit only return the first {@code limit} bytes