Package org.eclipse.jgit.api.errors

Examples of org.eclipse.jgit.api.errors.NoHeadException


    RevWalk revWalk = null;
    DirCacheCheckout dco = null;
    try {
      Ref head = repo.getRef(Constants.HEAD);
      if (head == null)
        throw new NoHeadException(
            JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
      StringBuilder refLogMessage = new StringBuilder("merge "); //$NON-NLS-1$

      // Check for FAST_FORWARD, ALREADY_UP_TO_DATE
      revWalk = new RevWalk(repo);

      // we know for now there is only one commit
      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);
        dco.checkout();
        RefUpdate refUpdate = repo
            .updateRef(head.getTarget().getName());
        refUpdate.setNewObjectId(objectId);
        refUpdate.setExpectedOldObjectId(null);
        refUpdate.setRefLogMessage("initial pull", false); //$NON-NLS-1$
        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);
View Full Code Here


    try {
      RevWalk revWalk = new RevWalk(reader);

      ObjectId headCommit = repo.resolve(Constants.HEAD);
      if (headCommit == null)
        throw new NoHeadException(JGitText.get().stashApplyWithoutHead);

      final ObjectId stashId = getStashId();
      RevCommit stashCommit = revWalk.parseCommit(stashId);
      if (stashCommit.getParentCount() != 2)
        throw new JGitInternalException(MessageFormat.format(
View Full Code Here

  private Ref getHead() throws GitAPIException {
    try {
      Ref head = repo.getRef(Constants.HEAD);
      if (head == null || head.getObjectId() == null)
        throw new NoHeadException(JGitText.get().headRequiredToStash);
      return head;
    } catch (IOException e) {
      throw new JGitInternalException(JGitText.get().stashFailed, e);
    }
  }
View Full Code Here

      // if no id is set, we should attempt to use HEAD
      if (id == null) {
        ObjectId objectId = repo.resolve(Constants.HEAD + "^{commit}"); //$NON-NLS-1$
        if (objectId == null)
          throw new NoHeadException(
              JGitText.get().tagOnRepoWithoutHEADCurrentlyNotSupported);

        newTag.setObjectId(objectId, Constants.OBJ_COMMIT);
      } else {
        newTag.setObjectId(id);
View Full Code Here

        }
      }

      Ref head = repo.getRef(Constants.HEAD);
      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}"); //$NON-NLS-1$
      if (headId == null && amend)
View Full Code Here

  }

  private RevCommit checkoutCurrentHead() throws IOException, NoHeadException {
    ObjectId headTree = repo.resolve(Constants.HEAD + "^{tree}"); //$NON-NLS-1$
    if (headTree == null)
      throw new NoHeadException(
          JGitText.get().cannotRebaseWithoutCurrentHead);
    DirCache dc = repo.lockDirCache();
    try {
      DirCacheCheckout dco = new DirCacheCheckout(repo, dc, headTree);
      dco.setFailOnConflict(false);
View Full Code Here

    treeWalk.reset();
    treeWalk.setRecursive(true);
    treeWalk.addTree(new DirCacheIterator(dc));
    ObjectId id = repo.resolve(Constants.HEAD + "^{tree}"); //$NON-NLS-1$
    if (id == null)
      throw new NoHeadException(
          JGitText.get().cannotRebaseWithoutCurrentHead);

    treeWalk.addTree(id);

    treeWalk.setFilter(TreeFilter.ANY_DIFF);
View Full Code Here

    String branchName;
    try {
      String fullBranch = repo.getFullBranch();
      if (fullBranch == null)
        throw new NoHeadException(
            JGitText.get().pullOnRepoWithoutHEADCurrentlyNotSupported);
      if (!fullBranch.startsWith(Constants.R_HEADS)) {
        // we can not pull if HEAD is detached and branch is not
        // specified explicitly
        throw new DetachedHeadException();
View Full Code Here

  private Ref getHead() throws GitAPIException {
    try {
      Ref head = repo.getRef(Constants.HEAD);
      if (head == null || head.getObjectId() == null)
        throw new NoHeadException(JGitText.get().headRequiredToStash);
      return head;
    } catch (IOException e) {
      throw new JGitInternalException(JGitText.get().stashFailed, e);
    }
  }
View Full Code Here

    RevWalk revWalk = null;
    DirCacheCheckout dco = null;
    try {
      Ref head = repo.getRef(Constants.HEAD);
      if (head == null)
        throw new NoHeadException(
            JGitText.get().commitOnRepoWithoutHEADCurrentlyNotSupported);
      StringBuilder refLogMessage = new StringBuilder("merge "); //$NON-NLS-1$

      // Check for FAST_FORWARD, ALREADY_UP_TO_DATE
      revWalk = new RevWalk(repo);

      // we know for now there is only one commit
      Ref ref = commits.get(0);

      refLogMessage.append(ref.getName());

      // handle annotated tags
      ref = repo.peel(ref);
      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); //$NON-NLS-1$
        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);
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.api.errors.NoHeadException

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.