aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2024-11-11 23:39:12 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2024-11-11 23:39:12 +0100
commit102733833c29ff84c093d54dc0554a1f73f89078 (patch)
tree3b7d36f8986f807dda9059037612dfd87b866557 /org.eclipse.jgit
parent9ed2e5c473e8334a20846e7fa0f5eb0aa369f0bb (diff)
parentd34f8b523638fc95b2e7006d02c9f6a756cbba85 (diff)
downloadjgit-102733833c29ff84c093d54dc0554a1f73f89078.tar.gz
jgit-102733833c29ff84c093d54dc0554a1f73f89078.zip
Merge branch 'stable-6.10' into stable-7.0
* 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
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java33
2 files changed, 26 insertions, 20 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
index 4fafc5a088..8fde3903d0 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java
@@ -1509,6 +1509,12 @@ public class GC {
public long numberOfPackFiles;
/**
+ * The number of pack files that were created after the last bitmap
+ * generation.
+ */
+ public long numberOfPackFilesAfterBitmap;
+
+ /**
* The number of objects stored as loose objects.
*/
public long numberOfLooseObjects;
@@ -1543,6 +1549,8 @@ public class GC {
final StringBuilder b = new StringBuilder();
b.append("numberOfPackedObjects=").append(numberOfPackedObjects); //$NON-NLS-1$
b.append(", numberOfPackFiles=").append(numberOfPackFiles); //$NON-NLS-1$
+ b.append(", numberOfPackFilesAfterBitmap=") //$NON-NLS-1$
+ .append(numberOfPackFilesAfterBitmap);
b.append(", numberOfLooseObjects=").append(numberOfLooseObjects); //$NON-NLS-1$
b.append(", numberOfLooseRefs=").append(numberOfLooseRefs); //$NON-NLS-1$
b.append(", numberOfPackedRefs=").append(numberOfPackedRefs); //$NON-NLS-1$
@@ -1567,8 +1575,11 @@ public class GC {
ret.numberOfPackedObjects += p.getIndex().getObjectCount();
ret.numberOfPackFiles++;
ret.sizeOfPackedObjects += p.getPackFile().length();
- if (p.getBitmapIndex() != null)
+ if (p.getBitmapIndex() != null) {
ret.numberOfBitmaps += p.getBitmapIndex().getBitmapCount();
+ } else {
+ ret.numberOfPackFilesAfterBitmap++;
+ }
}
File objDir = repo.getObjectsDirectory();
String[] fanout = objDir.list();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
index a503db9e85..997f4ed314 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
@@ -12,9 +12,13 @@
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.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;
@@ -722,14 +726,15 @@ public final class Constants {
* the 7-bit ASCII character space.
*/
public static byte[] encodeASCII(String s) {
- final byte[] r = new byte[s.length()];
- for (int k = r.length - 1; k >= 0; k--) {
- final char c = s.charAt(k);
- if (c > 127)
- throw new IllegalArgumentException(MessageFormat.format(JGitText.get().notASCIIString, s));
- r[k] = (byte) c;
+ try {
+ CharsetEncoder encoder = US_ASCII.newEncoder()
+ .onUnmappableCharacter(CodingErrorAction.REPORT)
+ .onMalformedInput(CodingErrorAction.REPORT);
+ return encoder.encode(CharBuffer.wrap(s)).array();
+ } catch (CharacterCodingException e) {
+ throw new IllegalArgumentException(
+ MessageFormat.format(JGitText.get().notASCIIString, s), e);
}
- return r;
}
/**
@@ -741,17 +746,7 @@ public final class Constants {
* default character encoding (UTF-8).
*/
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 {