Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.ObjectId


    pm.beginTask(JGitText.get().countingObjects, ProgressMonitor.UNKNOWN);
    for (DfsPackFile src : srcPacks) {
      List<ObjectIdWithOffset> want = new BlockList<ObjectIdWithOffset>();
      for (PackIndex.MutableEntry ent : src.getPackIndex(ctx)) {
        ObjectId id = ent.toObjectId();
        RevObject obj = rw.lookupOrNull(id);
        if (obj == null || !obj.has(added))
          want.add(new ObjectIdWithOffset(id, ent.getOffset()));
      }
View Full Code Here


        }
      }
    }

    if (nFmt == PACK_DELTA && reuseDeltas && reuseDeltaFor(otp)) {
      ObjectId baseId = next.getDeltaBase();
      ObjectToPack ptr = objectsMap.get(baseId);
      if (ptr != null && !ptr.isEdge()) {
        otp.setDeltaBase(ptr);
        otp.setReuseAsIs();
      } else if (thin && ptr != null && ptr.isEdge()) {
View Full Code Here

  }

  @Override
  public ObjectId insert(int type, byte[] data, int off, int len)
      throws IOException {
    ObjectId id = idFor(type, data, off, len);
    if (objectMap != null && objectMap.contains(id))
      return id;
    if (db.has(id))
      return id;
View Full Code Here

    RefDirectoryUpdate to = newUpdate(toName, false);
    return new RefDirectoryRename(from, to);
  }

  void stored(RefDirectoryUpdate update, FileSnapshot snapshot) {
    final ObjectId target = update.getNewObjectId().copy();
    final Ref leaf = update.getRef().getLeaf();
    putLooseRef(new LooseUnpeeled(snapshot, leaf.getName(), target));
  }
View Full Code Here

    fireRefsChanged();
  }

  void log(final RefUpdate update, final String msg, final boolean deref)
      throws IOException {
    final ObjectId oldId = update.getOldObjectId();
    final ObjectId newId = update.getNewObjectId();
    final Ref ref = update.getRef();

    PersonIdent ident = update.getRefLogIdent();
    if (ident == null)
      ident = new PersonIdent(parent);
View Full Code Here

      if (p.charAt(0) == '^') {
        if (last == null)
          throw new IOException(JGitText.get().peeledLineBeforeRef);

        ObjectId id = ObjectId.fromString(p.substring(1));
        last = new ObjectIdRef.PeeledTag(PACKED, last.getName(), last
            .getObjectId(), id);
        all.set(all.size() - 1, last);
        continue;
      }

      int sp = p.indexOf(' ');
      ObjectId id = ObjectId.fromString(p.substring(0, sp));
      String name = copy(p, sp + 1, p.length());
      ObjectIdRef cur;
      if (peeled)
        cur = new ObjectIdRef.PeeledNonTag(PACKED, name, id);
      else
View Full Code Here

    }

    if (n < OBJECT_ID_STRING_LENGTH)
      return null; // impossibly short object identifier; not a reference.

    final ObjectId id;
    try {
      id = ObjectId.fromString(buf, 0);
      if (ref != null && !ref.isSymbolic()
          && ref.getTarget().getObjectId().equals(id)) {
        currentSnapshot.setClean(otherSnapshot);
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

      if (head == null)
        throw new NoHeadException(
            JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);

      // determine the current HEAD and the commit it is referring to
      ObjectId headId = repo.resolve(Constants.HEAD + "^{commit}");
      if (headId != null)
        if (amend) {
          RevCommit previousCommit = new RevWalk(repo)
              .parseCommit(headId);
          RevCommit[] p = previousCommit.getParents();
          for (int i = 0; i < p.length; i++)
            parents.add(0, p[i].getId());
        } else {
          parents.add(0, headId);
        }

      // lock the index
      DirCache index = repo.lockDirCache();
      try {
        if (!only.isEmpty())
          index = createTemporaryIndex(headId, index);

        ObjectInserter odi = repo.newObjectInserter();
        try {
          // Write the index as tree to the object database. This may
          // fail for example when the index contains unmerged paths
          // (unresolved conflicts)
          ObjectId indexTreeId = index.writeTree(odi);

          if (insertChangeId)
            insertChangeId(indexTreeId);

          // Create a Commit object, populate it and write it
          CommitBuilder commit = new CommitBuilder();
          commit.setCommitter(committer);
          commit.setAuthor(author);
          commit.setMessage(message);

          commit.setParentIds(parents);
          commit.setTreeId(indexTreeId);
          ObjectId commitId = odi.insert(commit);
          odi.flush();

          RevWalk revWalk = new RevWalk(repo);
          try {
            RevCommit revCommit = revWalk.parseCommit(commitId);
            RefUpdate ru = repo.updateRef(Constants.HEAD);
            ru.setNewObjectId(commitId);
            String prefix = amend ? "commit (amend): " : "commit: ";
            ru.setRefLogMessage(
                prefix + revCommit.getShortMessage(), false);

            ru.setExpectedOldObjectId(headId);
            Result rc = ru.forceUpdate();
            switch (rc) {
            case NEW:
            case FORCED:
            case FAST_FORWARD: {
              setCallable(false);
              if (state == RepositoryState.MERGING_RESOLVED) {
                // Commit was successful. Now delete the files
                // used for merge commits
                repo.writeMergeCommitMsg(null);
                repo.writeMergeHeads(null);
              } else if (state == RepositoryState.CHERRY_PICKING_RESOLVED) {
                repo.writeMergeCommitMsg(null);
                repo.writeCherryPickHead(null);
              }
              return revCommit;
            }
            case REJECTED:
            case LOCK_FAILURE:
              throw new ConcurrentRefUpdateException(JGitText
                  .get().couldNotLockHEAD, ru.getRef(), rc);
            default:
              throw new JGitInternalException(MessageFormat
                  .format(JGitText.get().updatingRefFailed,
                      Constants.HEAD,
                      commitId.toString(), rc));
            }
          } finally {
            revWalk.release();
          }
        } finally {
View Full Code Here

          JGitText.get().exceptionCaughtDuringExecutionOfCommitCommand, e);
    }
  }

  private void insertChangeId(ObjectId treeId) throws IOException {
    ObjectId firstParentId = null;
    if (!parents.isEmpty())
      firstParentId = parents.get(0);
    ObjectId changeId = ChangeIdUtil.computeChangeId(treeId, firstParentId,
        author, committer, message);
    message = ChangeIdUtil.insertId(message, changeId);
    if (changeId != null)
      message = message.replaceAll("\nChange-Id: I"
          + ObjectId.zeroId().getName() + "\n", "\nChange-Id: I"
          + changeId.getName() + "\n");
  }
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.