Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.ObjectId


     */
    public static boolean addCommitProperties(Transformer transformer, File baseDir, int abbrevLen, Log log) {
        try {
            RepositoryBuilder builder = new RepositoryBuilder();
            Repository repository = builder.findGitDir(baseDir).readEnvironment().build();
            ObjectId objectId = repository.resolve(Constants.HEAD);
            if (objectId != null) {
                transformer.setParameter("repository.commit", objectId.getName());
                transformer.setParameter("repository.commit.short", objectId.abbreviate(abbrevLen).name());
                return true;
            } else {
                log.warn("Could not determine current repository commit hash.");
                return false;
            }
View Full Code Here


  }

  private void markReachable(final Set<ObjectId> have, final int maxTime)
      throws IOException {
    for (final Ref r : local.getAllRefs().values()) {
      ObjectId id = r.getPeeledObjectId();
      if (id == null)
        id = r.getObjectId();
      if (id == null)
        continue;
      parseReachable(id);
View Full Code Here

        continue;
      }

      final StringBuilder sb = new StringBuilder();
      final Ref advertisedRef = getRef(rru.getRemoteName());
      final ObjectId oldId = (advertisedRef == null ? ObjectId.zeroId()
          : advertisedRef.getObjectId());
      sb.append(oldId.name());
      sb.append(' ');
      sb.append(rru.getNewObjectId().name());
      sb.append(' ');
      sb.append(rru.getRemoteName());
      if (!sentCommand) {
View Full Code Here

        final int tab = line.indexOf('\t');
        if (tab < 0)
          throw invalidAdvertisement(line);

        String name;
        final ObjectId id;

        name = line.substring(tab + 1);
        id = ObjectId.fromString(line.substring(0, tab));
        if (name.endsWith("^{}")) { //$NON-NLS-1$
          name = name.substring(0, name.length() - 3);
View Full Code Here

          && refToCheck.getName().startsWith(Constants.R_HEADS);
      if (!force && exists)
        throw new RefAlreadyExistsException(MessageFormat.format(
            JGitText.get().refAlreadyExists, name));

      ObjectId startAt = getStartPoint();
      String startPointFullName = null;
      if (startPoint != null) {
        Ref baseRef = repo.getRef(startPoint);
        if (baseRef != null)
          startPointFullName = baseRef.getName();
View Full Code Here

  private ObjectId getStartPoint() throws AmbiguousObjectException,
      RefNotFoundException, IOException {
    if (startCommit != null)
      return startCommit.getId();
    ObjectId result = null;
    try {
      result = repo.resolve((startPoint == null) ? Constants.HEAD
          : startPoint);
    } catch (AmbiguousObjectException e) {
      throw e;
View Full Code Here

      return zeroid;
    }
    if (submoduleRepo == null)
      return zeroid;

    final ObjectId head;
    try {
      head = submoduleRepo.resolve(Constants.HEAD);
    } catch (IOException exception) {
      return zeroid;
    } finally {
      submoduleRepo.close();
    }
    if (head == null)
      return zeroid;
    final byte[] id = new byte[Constants.OBJECT_ID_LENGTH];
    head.copyRawTo(id, 0);
    return id;
  }
View Full Code Here

      Ref ref = commits.get(0);

      refLogMessage.append(ref.getName());

      // handle annotated tags
      ObjectId objectId = ref.getPeeledObjectId();
      if (objectId == null)
        objectId = ref.getObjectId();

      RevCommit srcCommit = revWalk.lookupCommit(objectId);

      ObjectId headId = head.getObjectId();
      if (headId == null) {
        revWalk.parseHeaders(srcCommit);
        dco = new DirCacheCheckout(repo,
            repo.lockDirCache(), srcCommit.getTree());
        dco.setFailOnConflict(true);
View Full Code Here

    diffFmt.setRepository(repo);
    diffFmt.setProgressMonitor(monitor);
    try {
      if (cached) {
        if (oldTree == null) {
          ObjectId head = repo.resolve(HEAD + "^{tree}");
          if (head == null)
            throw new NoHeadException(JGitText.get().cannotReadTree);
          CanonicalTreeParser p = new CanonicalTreeParser();
          ObjectReader reader = repo.newObjectReader();
          try {
View Full Code Here

      final boolean cherryPicking = state
          .equals(RepositoryState.CHERRY_PICKING)
          || state.equals(RepositoryState.CHERRY_PICKING_RESOLVED);

      // resolve the ref to a commit
      final ObjectId commitId;
      try {
        commitId = repo.resolve(ref);
        if (commitId == null) {
          // @TODO throw an InvalidRefNameException. We can't do that
          // now because this would break the API
          throw new JGitInternalException("Invalid ref " + ref
              + " specified");
        }
      } catch (IOException e) {
        throw new JGitInternalException(
            MessageFormat.format(JGitText.get().cannotRead, ref),
            e);
      }
      RevWalk rw = new RevWalk(repo);
      try {
        commit = rw.parseCommit(commitId);
      } catch (IOException e) {
        throw new JGitInternalException(
            MessageFormat.format(
            JGitText.get().cannotReadCommit, commitId.toString()),
            e);
      } finally {
        rw.release();
      }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.ObjectId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.