Package org.eclipse.jgit.api.errors

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


      case FAST_FORWARD:
      case FORCED:
      case NO_CHANGE:
        break;
      default:
        throw new JGitInternalException("Updating HEAD failed");
      }
      rup = repo.updateRef(Constants.HEAD);
      res = rup.link(headName);
      switch (res) {
      case FAST_FORWARD:
      case FORCED:
      case NO_CHANGE:
        break;
      default:
        throw new JGitInternalException("Updating HEAD failed");
      }
    }
  }
View Full Code Here


    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);
View Full Code Here

          throw new IOException("Could not fast-forward");
        }
      }
      return newCommit;
    } catch (RefAlreadyExistsException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } catch (RefNotFoundException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } catch (InvalidRefNameException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } catch (CheckoutConflictException e) {
      throw new JGitInternalException(e.getMessage(), e);
    }
  }
View Full Code Here

      }
    } else
      switch (repo.getRepositoryState()) {
      case SAFE:
        if (this.upstreamCommit == null)
          throw new JGitInternalException(MessageFormat
              .format(JGitText.get().missingRequiredParameter,
                  "upstream"));
        return;
      default:
        throw new WrongRepositoryStateException(MessageFormat.format(
View Full Code Here

          JGitText.get().abortingRebase, commitId),
          ProgressMonitor.UNKNOWN);

      DirCacheCheckout dco;
      if (commitId == null)
        throw new JGitInternalException(
            JGitText.get().abortingRebaseFailedNoOrigHead);
      ObjectId id = repo.resolve(commitId);
      RevCommit commit = walk.parseCommit(id);
      if (result.getStatus().equals(Status.FAILED)) {
        RevCommit head = walk.parseCommit(repo.resolve(Constants.HEAD));
        dco = new DirCacheCheckout(repo, head.getTree(),
            repo.lockDirCache(), commit.getTree());
      } else {
        dco = new DirCacheCheckout(repo, repo.lockDirCache(),
            commit.getTree());
      }
      dco.setFailOnConflict(false);
      dco.checkout();
      walk.release();
    } finally {
      monitor.endTask();
    }
    try {
      String headName = readFile(rebaseDir, HEAD_NAME);
      if (headName.startsWith(Constants.R_REFS)) {
        monitor.beginTask(MessageFormat.format(
            JGitText.get().resettingHead, headName),
            ProgressMonitor.UNKNOWN);

        // update the HEAD
        RefUpdate refUpdate = repo.updateRef(Constants.HEAD, false);
        Result res = refUpdate.link(headName);
        switch (res) {
        case FAST_FORWARD:
        case FORCED:
        case NO_CHANGE:
          break;
        default:
          throw new JGitInternalException(
              JGitText.get().abortingRebaseFailed);
        }
      }
      // cleanup the files
      FileUtils.delete(rebaseDir, FileUtils.RECURSIVE);
View Full Code Here

  public RebaseCommand setUpstream(AnyObjectId upstream) {
    try {
      this.upstreamCommit = walk.parseCommit(upstream);
      this.upstreamCommitName = upstream.name();
    } catch (IOException e) {
      throw new JGitInternalException(MessageFormat.format(
          JGitText.get().couldNotReadObjectWhileParsingCommit,
          upstream.name()), e);
    }
    return this;
  }
View Full Code Here

            .get().refNotResolved, upstream));
      upstreamCommit = walk.parseCommit(repo.resolve(upstream));
      upstreamCommitName = upstream;
      return this;
    } catch (IOException ioe) {
      throw new JGitInternalException(ioe.getMessage(), ioe);
    }
  }
View Full Code Here

      Result renameResult = rename.rename();

      setCallable(false);

      if (Result.RENAMED != renameResult)
        throw new JGitInternalException(MessageFormat.format(JGitText
            .get().renameBranchUnexpectedResult, renameResult
            .name()));

      if (fullNewName.startsWith(Constants.R_HEADS)) {
        String shortOldName = fullOldName.substring(Constants.R_HEADS
            .length());
        final StoredConfig repoConfig = repo.getConfig();
        // Copy all configuration values over to the new branch
        for (String name : repoConfig.getNames(
            ConfigConstants.CONFIG_BRANCH_SECTION, shortOldName)) {
          String[] values = repoConfig.getStringList(
              ConfigConstants.CONFIG_BRANCH_SECTION,
              shortOldName, name);
          if (values.length == 0)
            continue;
          // Keep any existing values already configured for the
          // new branch name
          String[] existing = repoConfig.getStringList(
              ConfigConstants.CONFIG_BRANCH_SECTION, newName,
              name);
          if (existing.length > 0) {
            String[] newValues = new String[values.length
                + existing.length];
            System.arraycopy(existing, 0, newValues, 0,
                existing.length);
            System.arraycopy(values, 0, newValues, existing.length,
                values.length);
            values = newValues;
          }

          repoConfig.setStringList(
              ConfigConstants.CONFIG_BRANCH_SECTION, newName,
              name, Arrays.asList(values));
        }
        repoConfig.unsetSection(ConfigConstants.CONFIG_BRANCH_SECTION,
            shortOldName);
        repoConfig.save();
      }

      Ref resultRef = repo.getRef(newName);
      if (resultRef == null)
        throw new JGitInternalException(
            JGitText.get().renameBranchFailedUnknownReason);
      return resultRef;
    } catch (IOException ioe) {
      throw new JGitInternalException(ioe.getMessage(), ioe);
    }
  }
View Full Code Here

      try {
        commitId = repo.resolve(ref + "^{commit}");
        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();
      }

      if (!filepaths.isEmpty()) {
        // reset [commit] -- paths
        resetIndexForPaths(commit);
        setCallable(false);
        return repo.getRef(Constants.HEAD);
      }

      // write the ref
      final RefUpdate ru = repo.updateRef(Constants.HEAD);
      ru.setNewObjectId(commitId);

      String refName = Repository.shortenRefName(ref);
      String message = refName + ": updating " + Constants.HEAD; //$NON-NLS-1$
      ru.setRefLogMessage(message, false);
      if (ru.forceUpdate() == RefUpdate.Result.LOCK_FAILURE)
        throw new JGitInternalException(MessageFormat.format(
            JGitText.get().cannotLock, ru.getName()));

      ObjectId origHead = ru.getOldObjectId();
      if (origHead != null)
        repo.writeOrigHead(origHead);

      switch (mode) {
        case HARD:
          checkoutIndex(commit);
          break;
        case MIXED:
          resetIndex(commit);
          break;
        case SOFT: // do nothing, only the ref was changed
          break;
        case KEEP: // TODO
        case MERGE: // TODO
          throw new UnsupportedOperationException();

      }

      if (mode != ResetType.SOFT) {
        if (merging)
          resetMerge();
        else if (cherryPicking)
          resetCherryPick();
        else if (repo.readSquashCommitMsg() != null)
          repo.writeSquashCommitMsg(null /* delete */);
      }

      setCallable(false);
      r = ru.getRef();
    } catch (IOException e) {
      throw new JGitInternalException(
          JGitText.get().exceptionCaughtDuringExecutionOfResetCommand,
          e);
    }

    return r;
View Full Code Here

   *            the mode of the reset command
   * @return this instance
   */
  public ResetCommand setMode(ResetType mode) {
    if (!filepaths.isEmpty())
      throw new JGitInternalException(MessageFormat.format(
          JGitText.get().illegalCombinationOfArguments,
          "[--mixed | --soft | --hard]", "<paths>..."));
    this.mode = mode;
    return this;
  }
View Full Code Here

TOP

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

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.