summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src
diff options
context:
space:
mode:
authorSebastian Schuberth <sebastian.schuberth@bosch.io>2022-01-05 18:21:33 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2022-02-03 00:21:25 +0100
commit20bdcf9ea82c390ee70180c3edb51888e7d237bc (patch)
tree686e5d55fbe4b13f165fd44a4dcd4f8f1ffcf601 /org.eclipse.jgit.pgm/src
parentf7707e402aade0f96576b9ab648382af5ba56c4b (diff)
downloadjgit-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.pgm/src')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java4
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java8
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java5
3 files changed, 13 insertions, 4 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java
index 2b49cf73d4..1a3a2f6f4b 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Blame.java
@@ -15,6 +15,7 @@ package org.eclipse.jgit.pgm;
import static java.lang.Integer.valueOf;
import static java.lang.Long.valueOf;
+import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH;
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_STRING_LENGTH;
import java.io.IOException;
@@ -116,7 +117,8 @@ class Blame extends TextBuiltin {
boolean autoAbbrev = abbrev == 0;
if (abbrev == 0) {
- abbrev = db.getConfig().getInt("core", "abbrev", 7); //$NON-NLS-1$ //$NON-NLS-2$
+ abbrev = db.getConfig().getInt("core", "abbrev", //$NON-NLS-1$ //$NON-NLS-2$
+ OBJECT_ID_ABBREV_STRING_LENGTH);
}
if (!showBlankBoundary) {
root = db.getConfig().getBoolean("blame", "blankboundary", false); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java
index ca4877fb34..27a3d90fad 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Merge.java
@@ -10,6 +10,8 @@
package org.eclipse.jgit.pgm;
+import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH;
+
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Map;
@@ -144,8 +146,10 @@ class Merge extends TextBuiltin {
case FAST_FORWARD:
ObjectId oldHeadId = oldHead.getObjectId();
if (oldHeadId != null) {
- String oldId = oldHeadId.abbreviate(7).name();
- String newId = result.getNewHead().abbreviate(7).name();
+ String oldId = oldHeadId
+ .abbreviate(OBJECT_ID_ABBREV_STRING_LENGTH).name();
+ String newId = result.getNewHead()
+ .abbreviate(OBJECT_ID_ABBREV_STRING_LENGTH).name();
outw.println(MessageFormat.format(CLIText.get().updating,
oldId, newId));
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java
index 030119ea34..c63532df60 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reflog.java
@@ -9,6 +9,8 @@
*/
package org.eclipse.jgit.pgm;
+import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH;
+
import java.io.IOException;
import java.util.Collection;
@@ -45,7 +47,8 @@ class Reflog extends TextBuiltin {
private String toString(ReflogEntry entry, int i) {
final StringBuilder s = new StringBuilder();
- s.append(entry.getNewId().abbreviate(7).name());
+ s.append(entry.getNewId().abbreviate(OBJECT_ID_ABBREV_STRING_LENGTH)
+ .name());
s.append(" "); //$NON-NLS-1$
s.append(ref == null ? Constants.HEAD : Repository.shortenRefName(ref));
s.append("@{" + i + "}:"); //$NON-NLS-1$ //$NON-NLS-2$