]> source.dussan.org Git - jgit.git/commitdiff
Merge branch 'stable-6.10' into stable-7.0 55/1203555/1
authorMatthias Sohn <matthias.sohn@sap.com>
Mon, 11 Nov 2024 22:39:12 +0000 (23:39 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 11 Nov 2024 22:39:12 +0000 (23:39 +0100)
* stable-6.10:
  Replace custom encoder Constants#encodeASCII by JDK implementation
  Replace custom encoder `Constants#encode` by JDK implementation
  Add `numberOfPackFilesAfterBitmap` to RepoStatistics
  Enhance CommitBuilder#parent to tolerate null parent

Change-Id: If05b0d474c728b54cab9af2b7416be30b2754d1b

1  2 
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java

index a503db9e85fcf34186d9c43bd0efad6fa9750698,1a2f735622e5a6a9c4a2af3a06139f13b98368de..997f4ed31417a783f35ac6c534868228f9b65de9
  
  package org.eclipse.jgit.lib;
  
+ import static java.nio.charset.StandardCharsets.US_ASCII;
  import static java.nio.charset.StandardCharsets.UTF_8;
  
- import java.nio.ByteBuffer;
 -import java.nio.charset.Charset;
+ import java.nio.CharBuffer;
+ import java.nio.charset.CharacterCodingException;
+ import java.nio.charset.CharsetEncoder;
+ import java.nio.charset.CodingErrorAction;
  import java.security.MessageDigest;
  import java.security.NoSuchAlgorithmException;
  import java.text.MessageFormat;
@@@ -739,19 -690,10 +744,9 @@@ public final class Constants 
         *            the string to convert. May contain any Unicode characters.
         * @return a byte array representing the requested string, encoded using the
         *         default character encoding (UTF-8).
 -       * @see #CHARACTER_ENCODING
         */
        public static byte[] encode(String str) {
-               final ByteBuffer bb = UTF_8.encode(str);
-               final int len = bb.limit();
-               if (bb.hasArray() && bb.arrayOffset() == 0) {
-                       final byte[] arr = bb.array();
-                       if (arr.length == len)
-                               return arr;
-               }
-               final byte[] arr = new byte[len];
-               bb.get(arr);
-               return arr;
+               return str.getBytes(UTF_8);
        }
  
        static {