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;
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$
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;
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));
}
*/
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;
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$
*/
package org.eclipse.jgit.api;
+import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
checkFile(new File(db.getWorkTree(), "a"), "first\n"
+ "<<<<<<< master\n" + "second\n" + "third\n" + "=======\n"
- + ">>>>>>> " + secondCommit.getId().abbreviate(7).name()
+ + ">>>>>>> "
+ + secondCommit.getId()
+ .abbreviate(OBJECT_ID_ABBREV_STRING_LENGTH).name()
+ " add second\n");
Iterator<RevCommit> history = git.log().call().iterator();
RevCommit revertCommit = history.next();
*/
package org.eclipse.jgit.api;
+import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH;
+
import java.io.IOException;
import java.text.MessageFormat;
import java.util.LinkedList;
final RevCommit srcParent = getParentCommit(srcCommit, revWalk);
String ourName = calculateOurName(headRef);
- String cherryPickName = srcCommit.getId().abbreviate(7).name()
+ String cherryPickName = srcCommit.getId().abbreviate(OBJECT_ID_ABBREV_STRING_LENGTH).name()
+ " " + srcCommit.getShortMessage(); //$NON-NLS-1$
Merger merger = strategy.newMerger(repo);
*/
package org.eclipse.jgit.api;
+import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH;
+
import java.io.IOException;
import java.text.MessageFormat;
import java.util.LinkedList;
revWalk.parseHeaders(srcParent);
String ourName = calculateOurName(headRef);
- String revertName = srcCommit.getId().abbreviate(7).name()
- + " " + srcCommit.getShortMessage(); //$NON-NLS-1$
+ String revertName = srcCommit.getId()
+ .abbreviate(OBJECT_ID_ABBREV_STRING_LENGTH).name() + " " //$NON-NLS-1$
+ + srcCommit.getShortMessage();
ResolveMerger merger = (ResolveMerger) strategy.newMerger(repo);
merger.setWorkingTreeIterator(new FileTreeIterator(repo));
*/
package org.eclipse.jgit.api;
+import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
builder.setParentId(headCommit);
builder.setTreeId(cache.writeTree(inserter));
builder.setMessage(MessageFormat.format(indexMessage, branch,
- headCommit.abbreviate(7).name(),
+ headCommit.abbreviate(OBJECT_ID_ABBREV_STRING_LENGTH)
+ .name(),
headCommit.getShortMessage()));
ObjectId indexCommit = inserter.insert(builder);
builder.setParentIds(new ObjectId[0]);
builder.setTreeId(untrackedDirCache.writeTree(inserter));
builder.setMessage(MessageFormat.format(MSG_UNTRACKED,
- branch, headCommit.abbreviate(7).name(),
+ branch,
+ headCommit
+ .abbreviate(OBJECT_ID_ABBREV_STRING_LENGTH)
+ .name(),
headCommit.getShortMessage()));
untrackedCommit = inserter.insert(builder);
}
builder.addParentId(untrackedCommit);
builder.setMessage(MessageFormat.format(
workingDirectoryMessage, branch,
- headCommit.abbreviate(7).name(),
+ headCommit.abbreviate(OBJECT_ID_ABBREV_STRING_LENGTH)
+ .name(),
headCommit.getShortMessage()));
builder.setTreeId(cache.writeTree(inserter));
commitId = inserter.insert(builder);
import static org.eclipse.jgit.diff.DiffEntry.ChangeType.RENAME;
import static org.eclipse.jgit.diff.DiffEntry.Side.NEW;
import static org.eclipse.jgit.diff.DiffEntry.Side.OLD;
+import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH;
import static org.eclipse.jgit.lib.Constants.encode;
import static org.eclipse.jgit.lib.Constants.encodeASCII;
import static org.eclipse.jgit.lib.FileMode.GITLINK;
private int context = 3;
- private int abbreviationLength = 7;
+ private int abbreviationLength = OBJECT_ID_ABBREV_STRING_LENGTH;
private DiffAlgorithm diffAlgorithm;
*/
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";
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;
*/
public AbbreviatedObjectId abbreviate(AnyObjectId objectId)
throws IOException {
- return abbreviate(objectId, 7);
+ return abbreviate(objectId, OBJECT_ID_ABBREV_STRING_LENGTH);
}
/**
package org.eclipse.jgit.transport;
+import static org.eclipse.jgit.lib.Constants.OBJECT_ID_ABBREV_STRING_LENGTH;
+
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.RefUpdate;
if (forceUpdate)
sb.append(" (forced)");
sb.append(" ");
- sb.append(oldObjectId == null ? "" : oldObjectId.abbreviate(7).name());
+ sb.append(oldObjectId == null ? ""
+ : oldObjectId.abbreviate(OBJECT_ID_ABBREV_STRING_LENGTH)
+ .name());
sb.append("..");
- sb.append(newObjectId == null ? "" : newObjectId.abbreviate(7).name());
+ sb.append(newObjectId == null ? ""
+ : newObjectId.abbreviate(OBJECT_ID_ABBREV_STRING_LENGTH)
+ .name());
sb.append("]");
return sb.toString();
}