Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.ObjectId


  }

  private boolean negotiate() throws IOException {
    okToGiveUp = Boolean.FALSE;

    ObjectId last = ObjectId.zeroId();
    List<ObjectId> peerHas = new ArrayList<ObjectId>(64);
    for (;;) {
      String line;
      try {
        line = pckIn.readString();
      } catch (EOFException eof) {
        throw eof;
      }

      if (line == PacketLineIn.END) {
        last = processHaveLines(peerHas, last);
        if (commonBase.isEmpty() || multiAck != MultiAck.OFF)
          pckOut.writeString("NAK\n");
        if (noDone && sentReady) {
          pckOut.writeString("ACK " + last.name() + "\n");
          return true;
        }
        if (!biDirectionalPipe)
          return false;
        pckOut.flush();

      } else if (line.startsWith("have ") && line.length() == 45) {
        peerHas.add(ObjectId.fromString(line.substring(5)));

      } else if (line.equals("done")) {
        last = processHaveLines(peerHas, last);

        if (commonBase.isEmpty())
          pckOut.writeString("NAK\n");

        else if (multiAck != MultiAck.OFF)
          pckOut.writeString("ACK " + last.name() + "\n");

        return true;

      } else {
        throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedGot, "have", line));
View Full Code Here


      for (;;) {
        RevObject obj;
        try {
          obj = q.next();
        } catch (MissingObjectException notFound) {
          ObjectId id = notFound.getObjectId();
          if (wantIds.contains(id)) {
            String msg = MessageFormat.format(
                JGitText.get().wantNotValid, id.name());
            pckOut.writeString("ERR " + msg);
            throw new PackProtocolException(msg, notFound);
          }
          continue;
        }
        if (obj == null)
          break;

        // If the object is still found in wantIds, the want
        // list wasn't parsed earlier, and was done in this batch.
        //
        if (wantIds.remove(obj)) {
          if (!advertised.contains(obj)) {
            String msg = MessageFormat.format(
                JGitText.get().wantNotValid, obj.name());
            pckOut.writeString("ERR " + msg);
            throw new PackProtocolException(msg);
          }

          if (!obj.has(WANT)) {
            obj.add(WANT);
            wantAll.add(obj);
          }

          if (!(obj instanceof RevCommit))
            obj.add(SATISFIED);

          if (obj instanceof RevTag) {
            RevObject target = walk.peel(obj);
            if (target instanceof RevCommit) {
              if (!target.has(WANT)) {
                target.add(WANT);
                wantAll.add(target);
              }
            }
          }

          if (!peerHasSet.contains(obj))
            continue;
        }

        last = obj;
        haveCnt++;

        if (obj instanceof RevCommit) {
          RevCommit c = (RevCommit) obj;
          if (oldestTime == 0 || c.getCommitTime() < oldestTime)
            oldestTime = c.getCommitTime();
        }

        if (obj.has(PEER_HAS))
          continue;

        obj.add(PEER_HAS);
        if (obj instanceof RevCommit)
          ((RevCommit) obj).carry(PEER_HAS);
        addCommonBase(obj);

        // If both sides have the same object; let the client know.
        //
        switch (multiAck) {
        case OFF:
          if (commonBase.size() == 1)
            pckOut.writeString("ACK " + obj.name() + "\n");
          break;
        case CONTINUE:
          pckOut.writeString("ACK " + obj.name() + " continue\n");
          break;
        case DETAILED:
          pckOut.writeString("ACK " + obj.name() + " common\n");
          break;
        }
      }
    } finally {
      q.release();
    }
    int missCnt = peerHas.size() - haveCnt;

    // If we don't have one of the objects but we're also willing to
    // create a pack at this point, let the client know so it stops
    // telling us about its history.
    //
    boolean didOkToGiveUp = false;
    if (0 < missCnt) {
      for (int i = peerHas.size() - 1; i >= 0; i--) {
        ObjectId id = peerHas.get(i);
        if (walk.lookupOrNull(id) == null) {
          didOkToGiveUp = true;
          if (okToGiveUp()) {
            switch (multiAck) {
            case OFF:
              break;
            case CONTINUE:
              pckOut.writeString("ACK " + id.name() + " continue\n");
              break;
            case DETAILED:
              pckOut.writeString("ACK " + id.name() + " ready\n");
              sentReady = true;
              break;
            }
          }
          break;
        }
      }
    }

    if (multiAck == MultiAck.DETAILED && !didOkToGiveUp && okToGiveUp()) {
      ObjectId id = peerHas.get(peerHas.size() - 1);
      sentReady = true;
      pckOut.writeString("ACK " + id.name() + " ready\n");
      sentReady = true;
    }

    try {
      preUploadHook.onEndNegotiateRound(this, wantAll, //
View Full Code Here

        rw = ow;
      }

      if (options.contains(OPTION_INCLUDE_TAG)) {
        for (Ref ref : refs.values()) {
          ObjectId objectId = ref.getObjectId();

          // If the object was already requested, skip it.
          if (wantAll.isEmpty()) {
            if (wantIds.contains(objectId))
              continue;
          } else {
            RevObject obj = rw.lookupOrNull(objectId);
            if (obj != null && obj.has(WANT))
              continue;
          }

          if (!ref.isPeeled())
            ref = db.peel(ref);

          ObjectId peeledId = ref.getPeeledObjectId();
          if (peeledId == null)
            continue;

          objectId = ref.getObjectId();
          if (pw.willInclude(peeledId) && !pw.willInclude(objectId))
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

        final String m = JGitText.get().errorInvalidProtocolWantedOldNewRef;
        sendError(m);
        throw new PackProtocolException(m);
      }

      final ObjectId oldId = ObjectId.fromString(line.substring(0, 40));
      final ObjectId newId = ObjectId.fromString(line.substring(41, 81));
      final String name = line.substring(82);
      final ReceiveCommand cmd = new ReceiveCommand(oldId, newId, name);
      if (name.equals(Constants.HEAD)) {
        cmd.setResult(Result.REJECTED_CURRENT_BRANCH);
      } else {
View Full Code Here

   * @throws IOException
   *             the note's blob cannot be read from the repository
   */
  public byte[] getCachedBytes(AnyObjectId id, int sizeLimit)
      throws LargeObjectException, MissingObjectException, IOException {
    ObjectId dataId = get(id);
    if (dataId != null)
      return reader.open(dataId).getCachedBytes(sizeLimit);
    else
      return null;
  }
View Full Code Here

   * @throws IOException
   *             the note data could not be stored in the repository.
   */
  public void set(AnyObjectId noteOn, String noteData, ObjectInserter ins)
      throws IOException {
    ObjectId dataId;
    if (noteData != null) {
      byte[] dataUTF8 = Constants.encode(noteData);
      dataId = ins.insert(Constants.OBJ_BLOB, dataUTF8);
    } else {
      dataId = null;
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

        final int tab = line.indexOf('\t');
        if (tab < 0)
          throw invalidAdvertisement(line);

        String name;
        final ObjectId id;

        name = line.substring(tab + 1);
        id = ObjectId.fromString(line.substring(0, tab));
        if (name.endsWith("^{}")) { //$NON-NLS-1$
          name = name.substring(0, name.length() - 3);
View Full Code Here

        continue;
      for (String e : entries) {
        if (e.length() != Constants.OBJECT_ID_STRING_LENGTH - 2)
          continue;
        try {
          ObjectId id = ObjectId.fromString(d + e);
          unpackedObjects.add(new UnpackedObjectId(id));
        } catch (IllegalArgumentException notAnObject) {
          // ignoring the file that does not represent loose object
        }
      }
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.