diff options
author | Sebastian Schuberth <sebastian.schuberth@bosch.io> | 2022-01-05 18:21:33 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2022-02-03 00:21:25 +0100 |
commit | 20bdcf9ea82c390ee70180c3edb51888e7d237bc (patch) | |
tree | 686e5d55fbe4b13f165fd44a4dcd4f8f1ffcf601 /org.eclipse.jgit/src/org/eclipse/jgit/lib | |
parent | f7707e402aade0f96576b9ab648382af5ba56c4b (diff) | |
download | jgit-20bdcf9ea82c390ee70180c3edb51888e7d237bc.tar.gz jgit-20bdcf9ea82c390ee70180c3edb51888e7d237bc.zip |
Introduce a constant for the length of an abbreviated hash string
Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch.io>
Change-Id: I196d58a813f7caa1965af4cf8e2f977ed4cdc350
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java | 9 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java | 4 |
2 files changed, 12 insertions, 1 deletions
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 92367ebd0c..cf2e69dbb5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java @@ -48,6 +48,15 @@ public final class Constants { */ public static final int OBJECT_ID_STRING_LENGTH = OBJECT_ID_LENGTH * 2; + /** + * The historic length of an abbreviated Git object hash string. Git 2.11 + * changed this static number to a dynamically calculated one that scales + * as the repository grows. + * + * @since 6.1 + */ + public static final int OBJECT_ID_ABBREV_STRING_LENGTH = 7; + /** Special name for the "HEAD" symbolic-ref. */ public static final String HEAD = "HEAD"; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java index a2c7381ce7..26c3ff6718 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java @@ -10,6 +10,8 @@ package org.eclipse.jgit.lib; +import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH; + import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -76,7 +78,7 @@ public abstract class ObjectReader implements AutoCloseable { */ public AbbreviatedObjectId abbreviate(AnyObjectId objectId) throws IOException { - return abbreviate(objectId, 7); + return abbreviate(objectId, OBJECT_ID_ABBREV_STRING_LENGTH); } /** |