Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.Ref


    checkCallable();
    RevWalk walk = new RevWalk(repo);
    NoteMap map = NoteMap.newEmptyMap();
    RevCommit notesCommit = null;
    try {
      Ref ref = repo.getRef(notesRef);
      // if we have a notes ref, use it
      if (ref != null) {
        notesCommit = walk.parseCommit(ref.getObjectId());
        map = NoteMap.read(walk.getObjectReader(), notesCommit);
      }
      return map.getNote(id);
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
View Full Code Here


    final List<RemoteRefUpdate> result = new LinkedList<RemoteRefUpdate>();
    final Collection<RefSpec> procRefs = expandPushWildcardsFor(db, specs);

    for (final RefSpec spec : procRefs) {
      String srcSpec = spec.getSource();
      final Ref srcRef = db.getRef(srcSpec);
      if (srcRef != null)
        srcSpec = srcRef.getName();

      String destSpec = spec.getDestination();
      if (destSpec == null) {
        // No destination (no-colon in ref-spec), DWIMery assumes src
        //
        destSpec = srcSpec;
      }

      if (srcRef != null && !destSpec.startsWith(Constants.R_REFS)) {
        // Assume the same kind of ref at the destination, e.g.
        // "refs/heads/foo:master", DWIMery assumes master is also
        // under "refs/heads/".
        //
        final String n = srcRef.getName();
        final int kindEnd = n.indexOf('/', Constants.R_REFS.length());
        destSpec = n.substring(0, kindEnd + 1) + destSpec;
      }

      final boolean forceUpdate = spec.isForceUpdate();
View Full Code Here

    RevWalk walk = new RevWalk(repo);
    ObjectInserter inserter = repo.newObjectInserter();
    NoteMap map = NoteMap.newEmptyMap();
    RevCommit notesCommit = null;
    try {
      Ref ref = repo.getRef(notesRef);
      // if we have a notes ref, use it
      if (ref != null) {
        notesCommit = walk.parseCommit(ref.getObjectId());
        map = NoteMap.read(walk.getObjectReader(), notesCommit);
      }
      map.set(id, message, inserter);
      commitNoteMap(walk, map, notesCommit, inserter,
          "Notes added by 'git notes add'");
View Full Code Here

    // 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

   * @return a {@link ReflogReader} for the supplied refname, or null if the
   *         named ref does not exist.
   * @throws IOException the ref could not be accessed.
   */
  public ReflogReader getReflogReader(String refName) throws IOException {
    Ref ref = getRef(refName);
    if (ref != null)
      return new ReflogReader(this, ref.getName());
    return null;
  }
View Full Code Here

    return database.getRepository();
  }

  @Override
  protected boolean tryLock(boolean deref) throws IOException {
    Ref dst = getRef();
    if (deref)
      dst = dst.getLeaf();
    String name = dst.getName();
    lock = new LockFile(database.fileFor(name), getRepository().getFS());
    if (lock.lock()) {
      dst = database.getRef(name);
      setOldObjectId(dst != null ? dst.getObjectId() : null);
      return true;
    } else {
      return false;
    }
  }
View Full Code Here

  }

  @Override
  public Ref getRef(final String needle) throws IOException {
    final RefList<Ref> packed = getPackedRefs();
    Ref ref = null;
    for (String prefix : SEARCH_PATH) {
      ref = readRef(prefix + needle, packed);
      if (ref != null) {
        ref = resolve(ref, 0, null, null, packed);
        break;
View Full Code Here

      loose = oldLoose;
    fireRefsChanged();

    RefList.Builder<Ref> symbolic = scan.symbolic;
    for (int idx = 0; idx < symbolic.size();) {
      final Ref symbolicRef = symbolic.get(idx);
      final Ref resolvedRef = resolve(symbolicRef, 0, prefix, loose, packed);
      if (resolvedRef != null && resolvedRef.getObjectId() != null) {
        symbolic.set(idx, resolvedRef);
        idx++;
      } else {
        // A broken symbolic reference, we have to drop it from the
        // collections the client is about to receive. Should be a
View Full Code Here

  @Override
  public List<Ref> getAdditionalRefs() throws IOException {
    List<Ref> ret = new LinkedList<Ref>();
    for (String name : additionalRefsNames) {
      Ref r = getRef(name);
      if (r != null)
        ret.add(r);
    }
    return ret;
  }
View Full Code Here

    }
  }

  @Override
  public Ref peel(final Ref ref) throws IOException {
    final Ref leaf = ref.getLeaf();
    if (leaf.isPeeled() || leaf.getObjectId() == null)
      return ref;

    ObjectIdRef newLeaf = doPeel(leaf);

    // Try to remember this peeling in the cache, so we don't have to do
    // it again in the future, but only if the reference is unchanged.
    if (leaf.getStorage().isLoose()) {
      RefList<LooseRef> curList = looseRefs.get();
      int idx = curList.find(leaf.getName());
      if (0 <= idx && curList.get(idx) == leaf) {
        LooseRef asPeeled = ((LooseRef) leaf).peel(newLeaf);
        RefList<LooseRef> newList = curList.set(idx, asPeeled);
        looseRefs.compareAndSet(curList, newList);
      }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.Ref

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.