Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.ObjectId


  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


      // loop through all refs to be reverted
      for (Ref src : commits) {
        // get the commit to be reverted
        // handle annotated tags
        ObjectId srcObjectId = src.getPeeledObjectId();
        if (srcObjectId == null)
          srcObjectId = src.getObjectId();
        RevCommit srcCommit = revWalk.parseCommit(srcObjectId);

        // get the parent of the commit to revert
View Full Code Here

    }
  }

  private RevCommit checkoutCurrentHead() throws IOException,
      NoHeadException, JGitInternalException {
    ObjectId headTree = repo.resolve(Constants.HEAD + "^{tree}");
    if (headTree == null)
      throw new NoHeadException(
          JGitText.get().cannotRebaseWithoutCurrentHead);
    DirCache dc = repo.lockDirCache();
    try {
View Full Code Here

    // determine whether we need to commit
    TreeWalk treeWalk = new TreeWalk(repo);
    treeWalk.reset();
    treeWalk.setRecursive(true);
    treeWalk.addTree(new DirCacheIterator(dc));
    ObjectId id = repo.resolve(Constants.HEAD + "^{tree}");
    if (id == null)
      throw new NoHeadException(
          JGitText.get().cannotRebaseWithoutCurrentHead);

    treeWalk.addTree(id);
View Full Code Here

    String headName;
    if (head.isSymbolic())
      headName = head.getTarget().getName();
    else
      headName = "detached HEAD";
    ObjectId headId = head.getObjectId();
    if (headId == null)
      throw new RefNotFoundException(MessageFormat.format(
          JGitText.get().refNotResolved, Constants.HEAD));
    RevCommit headCommit = walk.lookupCommit(headId);
    RevCommit upstream = walk.lookupCommit(upstreamCommit.getId());

    if (walk.isMergedInto(upstream, headCommit))
      return RebaseResult.UP_TO_DATE_RESULT;
    else if (walk.isMergedInto(headCommit, upstream)) {
      // head is already merged into upstream, fast-foward
      monitor.beginTask(MessageFormat.format(
          JGitText.get().resettingHead,
          upstreamCommit.getShortMessage()), ProgressMonitor.UNKNOWN);
      checkoutCommit(upstreamCommit);
      monitor.endTask();

      updateHead(headName, upstreamCommit);
      return RebaseResult.FAST_FORWARD_RESULT;
    }

    monitor.beginTask(JGitText.get().obtainingCommitsForCherryPick,
        ProgressMonitor.UNKNOWN);

    // determine the commits to be applied
    LogCommand cmd = new Git(repo).log().addRange(upstreamCommit,
        headCommit);
    Iterable<RevCommit> commitsToUse = cmd.call();

    List<RevCommit> cherryPickList = new ArrayList<RevCommit>();
    for (RevCommit commit : commitsToUse) {
      if (commit.getParentCount() != 1)
        throw new JGitInternalException(
            MessageFormat.format(
                JGitText.get().canOnlyCherryPickCommitsWithOneParent,
                commit.name(),
                Integer.valueOf(commit.getParentCount())));
      cherryPickList.add(commit);
    }

    Collections.reverse(cherryPickList);
    // create the folder for the meta information
    FileUtils.mkdir(rebaseDir);

    createFile(repo.getDirectory(), Constants.ORIG_HEAD, headId.name());
    createFile(rebaseDir, REBASE_HEAD, headId.name());
    createFile(rebaseDir, HEAD_NAME, headName);
    createFile(rebaseDir, ONTO, upstreamCommit.name());
    createFile(rebaseDir, INTERACTIVE, "");
    BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(
        new FileOutputStream(new File(rebaseDir, GIT_REBASE_TODO)),
        Constants.CHARACTER_ENCODING));
    fw.write("# Created by EGit: rebasing " + upstreamCommit.name()
        + " onto " + headId.name());
    fw.newLine();
    try {
      StringBuilder sb = new StringBuilder();
      ObjectReader reader = walk.getObjectReader();
      for (RevCommit commit : cherryPickList) {
View Full Code Here

    Ref head = repo.getRef(Constants.HEAD);
    if (head == null || head.getObjectId() == null)
      throw new RefNotFoundException(MessageFormat.format(
          JGitText.get().refNotResolved, Constants.HEAD));

    ObjectId headId = head.getObjectId();
    if (headId == null)
      throw new RefNotFoundException(MessageFormat.format(
          JGitText.get().refNotResolved, Constants.HEAD));
    RevCommit headCommit = walk.lookupCommit(headId);
    if (walk.isMergedInto(newCommit, headCommit))
View Full Code Here

   * @throws RefNotFoundException
   */
  public RebaseCommand setUpstream(String upstream)
      throws RefNotFoundException {
    try {
      ObjectId upstreamId = repo.resolve(upstream);
      if (upstreamId == null)
        throw new RefNotFoundException(MessageFormat.format(JGitText
            .get().refNotResolved, upstream));
      upstreamCommit = walk.parseCommit(repo.resolve(upstream));
      return this;
View Full Code Here

         newHead = headCommit;

         // get the commit to be cherry-picked
         // handle annotated tags
         ObjectId srcObjectId = src.getPeeledObjectId();
         if (srcObjectId == null)
            srcObjectId = src.getObjectId();
         RevCommit srcCommit = revWalk.parseCommit(srcObjectId);

         // get the parent of the commit to cherry-pick
View Full Code Here

  public void load() throws IOException, ConfigInvalidException {
    final FileSnapshot oldSnapshot = snapshot;
    final FileSnapshot newSnapshot = FileSnapshot.save(getFile());
    try {
      final byte[] in = IO.readFully(getFile());
      final ObjectId newHash = hash(in);
      if (hash.equals(newHash)) {
        if (oldSnapshot.equals(newSnapshot))
          oldSnapshot.setClean(newSnapshot);
        else
          snapshot = newSnapshot;
View Full Code Here

    case Constants.OBJ_REF_DELTA: {
      len -= p;
      len -= Constants.OBJECT_ID_LENGTH;
      readFully(pos + p, ib, 0, 20, ctx);
      ObjectId id = ObjectId.fromRaw(ib);
      r.format = StoredObjectRepresentation.PACK_DELTA;
      r.baseId = id;
      r.length = len;
      return;
    }
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.