Examples of Ref


Examples of org.eclipse.jgit.lib.Ref

    // we check the updates to see which of the updated branches
    // corresponds
    // to the remote branch name
    AnyObjectId commitToMerge;
    if (isRemote) {
      Ref r = null;
      if (fetchRes != null) {
        r = fetchRes.getAdvertisedRef(remoteBranchName);
        if (r == null)
          r = fetchRes.getAdvertisedRef(Constants.R_HEADS
              + remoteBranchName);
      }
      if (r == null)
        throw new JGitInternalException(MessageFormat.format(JGitText
            .get().couldNotGetAdvertisedRef, remoteBranchName));
      else
        commitToMerge = r.getObjectId();
    } else {
      try {
        commitToMerge = repo.resolve(remoteBranchName);
        if (commitToMerge == null)
          throw new RefNotFoundException(MessageFormat.format(
View Full Code Here

Examples of org.eclipse.jgit.lib.Ref

  private void checkout(Repository clonedRepo, FetchResult result)
      throws JGitInternalException,
      MissingObjectException, IncorrectObjectTypeException, IOException {

    Ref head = result.getAdvertisedRef(branch);
    if (branch.equals(Constants.HEAD)) {
      Ref foundBranch = findBranchToCheckout(result);
      if (foundBranch != null)
        head = foundBranch;
    }

    if (head == null || head.getObjectId() == null)
View Full Code Here

Examples of org.eclipse.jgit.lib.Ref

    update.setProgressMonitor(monitor);
    update.call();
  }

  private Ref findBranchToCheckout(FetchResult result) {
    final Ref idHEAD = result.getAdvertisedRef(Constants.HEAD);
    if (idHEAD == null)
      return null;

    Ref master = result.getAdvertisedRef(Constants.R_HEADS
        + Constants.MASTER);
    if (master != null && master.getObjectId().equals(idHEAD.getObjectId()))
      return master;

    Ref foundBranch = null;
    for (final Ref r : result.getAdvertisedRefs()) {
      final String n = r.getName();
      if (!n.startsWith(Constants.R_HEADS))
        continue;
      if (r.getObjectId().equals(idHEAD.getObjectId())) {
View Full Code Here

Examples of org.eclipse.jgit.lib.Ref

          // should really not happen
          throw new JGitInternalException(e.getMessage(), e);
        }
      }

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

Examples of org.eclipse.jgit.lib.Ref

      avail.put(r.getObjectId(), r);

    final Collection<Ref> wants = new ArrayList<Ref>(askFor.values());
    askFor.clear();
    for (final Ref want : wants) {
      final Ref newRef = avail.get(want.getObjectId());
      if (newRef != null) {
        askFor.put(newRef.getObjectId(), newRef);
      } else {
        removeFetchHeadRecord(want.getObjectId());
        removeTrackingRefUpdate(want.getObjectId());
      }
    }
View Full Code Here

Examples of org.eclipse.jgit.lib.Ref

    }
  }

  private void expandSingle(final RefSpec spec, final Set<Ref> matched)
      throws TransportException {
    final Ref src = conn.getRef(spec.getSource());
    if (src == null) {
      throw new TransportException(MessageFormat.format(JGitText.get().remoteDoesNotHaveSpec, spec.getSource()));
    }
    if (matched.add(src))
      want(src, spec);
View Full Code Here

Examples of org.eclipse.jgit.lib.Ref

    final Map<String, Ref> haveRefs = transport.local.getAllRefs();
    for (final Ref r : conn.getRefs()) {
      if (!isTag(r))
        continue;

      Ref local = haveRefs.get(r.getName());
      ObjectId obj = r.getObjectId();

      if (r.getPeeledObjectId() == null) {
        if (local != null && obj.equals(local.getObjectId()))
          continue;
        if (askFor.containsKey(obj) || transport.local.hasObject(obj))
          wantTag(r);
        else
          additionalTags.add(r);
        continue;
      }

      if (local != null) {
        if (!obj.equals(local.getObjectId()))
          wantTag(r);
      } else if (askFor.containsKey(r.getPeeledObjectId())
          || transport.local.hasObject(r.getPeeledObjectId()))
        wantTag(r);
      else
View Full Code Here

Examples of org.eclipse.jgit.lib.Ref

  private void expandFetchTags() throws TransportException {
    final Map<String, Ref> haveRefs = transport.local.getAllRefs();
    for (final Ref r : conn.getRefs()) {
      if (!isTag(r))
        continue;
      final Ref local = haveRefs.get(r.getName());
      if (local == null || !r.getObjectId().equals(local.getObjectId()))
        wantTag(r);
    }
  }
View Full Code Here

Examples of org.eclipse.jgit.lib.Ref

      String fullNewName;
      if (repo.getRef(newName) != null)
        throw new RefAlreadyExistsException(MessageFormat.format(
            JGitText.get().refAlreadyExists, newName));
      if (oldName != null) {
        Ref ref = repo.getRef(oldName);
        if (ref == null)
          throw new RefNotFoundException(MessageFormat.format(
              JGitText.get().refNotResolved, oldName));
        if (ref.getName().startsWith(Constants.R_TAGS))
          throw new RefNotFoundException(MessageFormat.format(
              JGitText.get().renameBranchFailedBecauseTag,
              oldName));
        fullOldName = ref.getName();
      } else {
        fullOldName = repo.getFullBranch();
        if (ObjectId.isId(fullOldName))
          throw new DetachedHeadException();
      }

      if (fullOldName.startsWith(Constants.R_REMOTES))
        fullNewName = Constants.R_REMOTES + newName;
      else {
        fullNewName = Constants.R_HEADS + newName;
      }

      if (!Repository.isValidRefName(fullNewName))
        throw new InvalidRefNameException(MessageFormat.format(JGitText
            .get().branchNameInvalid, fullNewName));

      RefRename rename = repo.renameRef(fullOldName, fullNewName);
      Result renameResult = rename.rename();

      setCallable(false);

      boolean ok = Result.RENAMED == renameResult;

      if (ok) {
        if (fullNewName.startsWith(Constants.R_HEADS)) {
          // move the upstream configuration over to the new branch
          String shortOldName = fullOldName
              .substring(Constants.R_HEADS.length());
          final StoredConfig repoConfig = repo.getConfig();
          String oldRemote = repoConfig.getString(
              ConfigConstants.CONFIG_BRANCH_SECTION,
              shortOldName, ConfigConstants.CONFIG_KEY_REMOTE);
          if (oldRemote != null) {
            repoConfig.setString(
                ConfigConstants.CONFIG_BRANCH_SECTION, newName,
                ConfigConstants.CONFIG_KEY_REMOTE, oldRemote);
          }
          String oldMerge = repoConfig.getString(
              ConfigConstants.CONFIG_BRANCH_SECTION,
              shortOldName, ConfigConstants.CONFIG_KEY_MERGE);
          if (oldMerge != null) {
            repoConfig.setString(
                ConfigConstants.CONFIG_BRANCH_SECTION, newName,
                ConfigConstants.CONFIG_KEY_MERGE, oldMerge);
          }
          repoConfig
              .unsetSection(
                  ConfigConstants.CONFIG_BRANCH_SECTION,
                  shortOldName);
          repoConfig.save();
        }

      } else
        throw new JGitInternalException(MessageFormat.format(JGitText
            .get().renameBranchUnexpectedResult, renameResult
            .name()));

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

Examples of org.eclipse.jgit.lib.Ref

    if (!url.startsWith("./") && !url.startsWith("../"))
      return url;

    String remoteName = null;
    // Look up remote URL associated wit HEAD ref
    Ref ref = parent.getRef(Constants.HEAD);
    if (ref != null) {
      if (ref.isSymbolic())
        ref = ref.getLeaf();
      remoteName = parent.getConfig().getString(
          ConfigConstants.CONFIG_BRANCH_SECTION,
          Repository.shortenRefName(ref.getName()),
          ConfigConstants.CONFIG_KEY_REMOTE);
    }

    // Fall back to 'origin' if current HEAD ref has no remote URL
    if (remoteName == null)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.