Example usage for org.eclipse.jgit.lib Constants OBJECT_ID_LENGTH

List of usage examples for org.eclipse.jgit.lib Constants OBJECT_ID_LENGTH

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Constants OBJECT_ID_LENGTH.

Prototype

int OBJECT_ID_LENGTH

To view the source code for org.eclipse.jgit.lib Constants OBJECT_ID_LENGTH.

Click Source Link

Document

A Git object hash is 160 bits, i.e.

Usage

From source file:com.google.gerrit.gpg.PublicKeyStore.java

License:Apache License

static ObjectId keyObjectId(long keyId) {
    byte[] buf = new byte[Constants.OBJECT_ID_LENGTH];
    NB.encodeInt64(buf, 0, keyId);/* w w w .j a  va 2s. c o m*/
    return ObjectId.fromRaw(buf);
}

From source file:com.google.gerrit.server.git.gpg.PublicKeyStore.java

License:Apache License

static ObjectId keyObjectId(long keyId) {
    ByteBuffer buf = ByteBuffer.wrap(new byte[Constants.OBJECT_ID_LENGTH]);
    buf.putLong(keyId);/*  w  ww  .  j ava2 s. c  o m*/
    return ObjectId.fromRaw(buf.array());
}

From source file:com.google.gitiles.doc.DocServlet.java

License:Open Source License

private String etag(SourceFile srcmd, SourceFile navmd) {
    byte[] b = new byte[Constants.OBJECT_ID_LENGTH];
    Hasher h = Hashing.sha1().newHasher();
    h.putInt(ETAG_GEN);//from  www  . j a v  a2s.  c om

    renderer.getTemplateHash(SOY_FILE).writeBytesTo(b, 0, b.length);
    h.putBytes(b);

    if (navmd != null) {
        navmd.id.copyRawTo(b, 0);
        h.putBytes(b);
    }

    srcmd.id.copyRawTo(b, 0);
    h.putBytes(b);
    return h.hash().toString();
}

From source file:jetbrains.buildServer.buildTriggers.vcs.git.submodules.SubmoduleAwareTreeIterator.java

License:Apache License

/**
 * Move iterator to the specific entry.//from  ww  w  .  ja  va 2s.c  o  m
 *
 * @throws CorruptObjectException in case of submodule processing problem
 */
protected void movedToEntry() throws CorruptObjectException {
    myIsEof = eof();
    if (myIsEof) {
        return;
    }
    int wrappedMode = myWrappedIterator.getEntryRawMode();
    myIsOnSubmodule = checkoutSubmodules() && GITLINK_MODE_BITS == wrappedMode;
    mode = myIsOnSubmodule ? TREE_MODE_BITS : wrappedMode;
    if (myIsOnSubmodule) {
        String entryPath = myWrappedIterator.getEntryPathString();
        try {
            mySubmoduleCommit = getSubmoduleCommit(entryPath, myWrappedIterator.getEntryObjectId());
        } catch (Exception e) {
            if (mySubmodulesPolicy.isIgnoreSubmodulesErrors()) {
                if (myLogSubmoduleErrors)
                    LOG.warn("Ignore submodule error: \"" + e.getMessage()
                            + "\". It seems to be fixed in one of the later commits.");
                mySubmoduleCommit = null;
                myIsOnSubmodule = false;
                mySubmoduleError = true;
                mode = wrappedMode;
            } else {
                if (e instanceof CorruptObjectException) {
                    throw (CorruptObjectException) e;
                } else {
                    CorruptObjectException ex = new CorruptObjectException(myWrappedIterator.getEntryObjectId(),
                            e.getMessage());
                    ex.initCause(e);
                    throw ex;
                }
            }
        }
        if (myIdBuffer == null) {
            myIdBuffer = new byte[Constants.OBJECT_ID_LENGTH];
        }
        if (mySubmoduleCommit != null) {
            mySubmoduleCommit.getTree().getId().copyRawTo(myIdBuffer, 0);
        }
    } else {
        mySubmoduleCommit = null;
    }
    // copy name
    final int nameLength = myWrappedIterator.getNameLength();
    final int pathLength = nameLength + pathOffset;
    ensurePathCapacity(pathLength, pathOffset);
    myWrappedIterator.getName(path, pathOffset);
    pathLen = pathLength;
}

From source file:org.gitective.tests.CalendarTest.java

License:Open Source License

/**
 * Test proper resize of internal arrays of {@link UserCommitActivity}
 * /*from  www.j a v a2 s  .com*/
 * @throws Exception
 */
@Test
public void resizeBySizeAndGrowth() throws Exception {
    RevCommit commit = add("test.txt", "content");
    UserCommitActivity user = new UserCommitActivity("a", "b");
    final int size = (UserCommitActivity.SIZE * UserCommitActivity.GROWTH) + 2;
    for (int i = 0; i < size; i++)
        user.include(commit, author);
    assertEquals(size, user.getCount());
    byte[] commitId = new byte[Constants.OBJECT_ID_LENGTH];
    commit.copyRawTo(commitId, 0);
    for (byte[] id : user.getRawIds())
        assertTrue(Arrays.equals(commitId, id));
    for (ObjectId id : user.getIds())
        assertEquals(commit, id);
}