Package org.eclipse.jgit.revwalk

Examples of org.eclipse.jgit.revwalk.RevCommit


      final Date maxWhen = new Date(maxTime * 1000L);
      walk.sort(RevSort.COMMIT_TIME_DESC);
      walk.markStart(reachableCommits);
      walk.setRevFilter(CommitTimeRevFilter.after(maxWhen));
      for (;;) {
        final RevCommit c = walk.next();
        if (c == null)
          break;
        if (c.has(ADVERTISED) && !c.has(COMMON)) {
          // This is actually going to be a common commit, but
          // our peer doesn't know that fact yet.
          //
          c.add(COMMON);
          c.carry(COMMON);
          reachableCommits.add(c);
        }
      }
    }
  }
View Full Code Here


    }
  }

  private void parseReachable(ObjectId id) {
    try {
      RevCommit o = walk.parseCommit(id);
      if (!o.has(REACHABLE)) {
        o.add(REACHABLE);
        reachableCommits.add(o);
      }
    } catch (IOException readError) {
      // If we cannot read the value of the ref skip it.
    }
View Full Code Here

    if (statelessRPC)
      state.writeTo(out, null);

    negotiateBegin();
    SEND_HAVES: for (;;) {
      final RevCommit c = walk.next();
      if (c == null)
        break SEND_HAVES;

      pckOut.writeString("have " + c.getId().name() + "\n");
      havesSent++;
      havesSinceLastContinue++;

      if ((31 & havesSent) != 0) {
        // We group the have lines into blocks of 32, each marked
View Full Code Here

      newHead.disableRefLog();
      newHead.link(head.getName());
      addMergeConfig(clonedRepo, head);
    }

    final RevCommit commit = parseCommit(clonedRepo, head);

    boolean detached = !head.getName().startsWith(Constants.R_HEADS);
    RefUpdate u = clonedRepo.updateRef(Constants.HEAD, detached);
    u.setNewObjectId(commit.getId());
    u.forceUpdate();

    if (!bare) {
      DirCache dc = clonedRepo.lockDirCache();
      DirCacheCheckout co = new DirCacheCheckout(clonedRepo, dc,
          commit.getTree());
      co.checkout();
      if (cloneSubmodules)
        cloneSubmodules(clonedRepo);
    }
  }
View Full Code Here

  private RevCommit parseCommit(final Repository clonedRepo, final Ref ref)
      throws MissingObjectException, IncorrectObjectTypeException,
      IOException {
    final RevWalk rw = new RevWalk(clonedRepo);
    final RevCommit commit;
    try {
      commit = rw.parseCommit(ref.getObjectId());
    } finally {
      rw.release();
    }
View Full Code Here

      if (startPointFullName == null) {
        String baseCommit;
        if (startCommit != null)
          baseCommit = startCommit.getShortMessage();
        else {
          RevCommit commit = revWalk.parseCommit(repo
              .resolve(startPoint));
          baseCommit = commit.getShortMessage();
        }
        if (exists)
          refLogMessage = "branch: Reset start-point to commit "
              + baseCommit;
        else
View Full Code Here

      // 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);
        dco.checkout();
        RefUpdate refUpdate = repo
            .updateRef(head.getTarget().getName());
        refUpdate.setNewObjectId(objectId);
        refUpdate.setExpectedOldObjectId(null);
        refUpdate.setRefLogMessage("initial pull", false);
        if (refUpdate.update() != Result.NEW)
          throw new NoHeadException(
              JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
        setCallable(false);
        return new MergeResult(srcCommit, srcCommit, new ObjectId[] {
            null, srcCommit }, MergeStatus.FAST_FORWARD,
            mergeStrategy, null, null);
      }

      RevCommit headCommit = revWalk.lookupCommit(headId);

      if (revWalk.isMergedInto(srcCommit, headCommit)) {
        setCallable(false);
        return new MergeResult(headCommit, srcCommit, new ObjectId[] {
            headCommit, srcCommit },
            MergeStatus.ALREADY_UP_TO_DATE, mergeStrategy, null, null);
      } else if (revWalk.isMergedInto(headCommit, srcCommit)) {
        // FAST_FORWARD detected: skip doing a real merge but only
        // update HEAD
        refLogMessage.append(": " + MergeStatus.FAST_FORWARD);
        dco = new DirCacheCheckout(repo,
            headCommit.getTree(), repo.lockDirCache(),
            srcCommit.getTree());
        dco.setFailOnConflict(true);
        dco.checkout();

        updateHead(refLogMessage, srcCommit, headId);
        setCallable(false);
        return new MergeResult(srcCommit, srcCommit, new ObjectId[] {
            headCommit, srcCommit }, MergeStatus.FAST_FORWARD,
            mergeStrategy, null, null);
      } else {

        String mergeMessage = new MergeMessageFormatter().format(
            commits, head);
        repo.writeMergeCommitMsg(mergeMessage);
        repo.writeMergeHeads(Arrays.asList(ref.getObjectId()));
        Merger merger = mergeStrategy.newMerger(repo);
        boolean noProblems;
        Map<String, org.eclipse.jgit.merge.MergeResult<?>> lowLevelResults = null;
        Map<String, MergeFailureReason> failingPaths = null;
        List<String> unmergedPaths = null;
        if (merger instanceof ResolveMerger) {
          ResolveMerger resolveMerger = (ResolveMerger) merger;
          resolveMerger.setCommitNames(new String[] {
              "BASE", "HEAD", ref.getName() });
          resolveMerger.setWorkingTreeIterator(new FileTreeIterator(repo));
          noProblems = merger.merge(headCommit, srcCommit);
          lowLevelResults = resolveMerger
              .getMergeResults();
          failingPaths = resolveMerger.getFailingPaths();
          unmergedPaths = resolveMerger.getUnmergedPaths();
        } else
          noProblems = merger.merge(headCommit, srcCommit);
        refLogMessage.append(": Merge made by ");
        refLogMessage.append(mergeStrategy.getName());
        refLogMessage.append('.');
        if (noProblems) {
          dco = new DirCacheCheckout(repo,
              headCommit.getTree(), repo.lockDirCache(),
              merger.getResultTreeId());
          dco.setFailOnConflict(true);
          dco.checkout();

          RevCommit newHead = new Git(getRepository()).commit()
              .setReflogComment(refLogMessage.toString()).call();
          return new MergeResult(newHead.getId(),
              null, new ObjectId[] {
                  headCommit.getId(), srcCommit.getId() },
              MergeStatus.MERGED, mergeStrategy, null, null);
        } else {
          if (failingPaths != null) {
View Full Code Here

   */
  public Ref call() throws IOException {
    checkCallable();

    Ref r;
    RevCommit commit;

    try {
      RepositoryState state = repo.getRepositoryState();
      final boolean merging = state.equals(RepositoryState.MERGING)
          || state.equals(RepositoryState.MERGING_RESOLVED);
View Full Code Here

        if (o instanceof RevTree)
          ow.markUninteresting(o);
      }
    }

    RevCommit c;
    while ((c = ow.next()) != null) {
      if (checkReferencedIsReachable //
          && !c.has(RevFlag.UNINTERESTING) //
          && !providedObjects.contains(c))
        throw new MissingObjectException(c, Constants.TYPE_COMMIT);
    }

    RevObject o;
View Full Code Here

      } catch (IncorrectObjectTypeException notCommit) {
        // Ignore non-commits in this loop.
      }
    }

    RevCommit o;
    while ((o = depthWalk.next()) != null) {
      DepthWalk.Commit c = (DepthWalk.Commit) o;

      // Commits at the boundary which aren't already shallow in
      // the client need to be marked as such
      if (c.getDepth() == depth && !clientShallowCommits.contains(c))
        pckOut.writeString("shallow " + o.name());

      // Commits not on the boundary which are shallow in the client
      // need to become unshallowed
      if (c.getDepth() < depth && clientShallowCommits.contains(c)) {
        unshallowCommits.add(c.copy());
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.revwalk.RevCommit

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.