Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.ObjectId


          // it seams that there is concurrent access to tree
          // variable, therefore we need to keep references to
          // entryFileMode and entryObjectId in local
          // variables
          final FileMode entryFileMode = tree.getEntryFileMode();
          final ObjectId entryObjectId = tree.getEntryObjectId();
          edit.add(new DirCacheEditor.PathEdit(path) {
            @Override
            public void apply(DirCacheEntry ent) {
              ent.setFileMode(entryFileMode);
              ent.setObjectId(entryObjectId);
View Full Code Here


      break;
    }

    case Constants.OBJ_REF_DELTA: {
      c = fill(Source.INPUT, 20);
      final ObjectId base = ObjectId.fromRaw(buf, c);
      System.arraycopy(buf, c, hdrBuf, hdrPtr, 20);
      hdrPtr += 20;
      use(20);
      DeltaChain r = baseById.get(base);
      if (r == null) {
View Full Code Here

    }
  }

  private SubmoduleStatus getStatus(SubmoduleWalk generator)
      throws IOException, ConfigInvalidException {
    ObjectId id = generator.getObjectId();
    String path = generator.getPath();

    // Report missing if no path in .gitmodules file
    if (generator.getModulesPath() == null)
      return new SubmoduleStatus(SubmoduleStatusType.MISSING, path, id);

    // Report uninitialized if no URL in config file
    if (generator.getConfigUrl() == null)
      return new SubmoduleStatus(SubmoduleStatusType.UNINITIALIZED, path,
          id);

    // Report uninitialized if no submodule repository
    Repository subRepo = generator.getRepository();
    if (subRepo == null)
      return new SubmoduleStatus(SubmoduleStatusType.UNINITIALIZED, path,
          id);

    ObjectId headId = subRepo.resolve(Constants.HEAD);

    // Report uninitialized if no HEAD commit in submodule repository
    if (headId == null)
      return new SubmoduleStatus(SubmoduleStatusType.UNINITIALIZED, path,
          id, headId);

    // Report checked out if HEAD commit is different than index commit
    if (!headId.equals(id))
      return new SubmoduleStatus(SubmoduleStatusType.REV_CHECKED_OUT,
          path, id, headId);

    // Report initialized if HEAD commit is the same as the index commit
    return new SubmoduleStatus(SubmoduleStatusType.INITIALIZED, path, id,
View Full Code Here

      walk.setRevFilter(SkipRevFilter.create(skip));
    else if (maxCount > -1)
      walk.setRevFilter(MaxCountRevFilter.create(maxCount));
    if (!startSpecified) {
      try {
        ObjectId headId = repo.resolve(Constants.HEAD);
        if (headId == null)
          throw new NoHeadException(
              JGitText.get().noHEADExistsAndNoExplicitStartingRevisionWasSpecified);
        add(headId);
      } catch (IOException e) {
View Full Code Here

   * @throws IOException
   *             the references could not be accessed
   */
  public LogCommand all() throws IOException {
    for (Ref ref : getRepository().getAllRefs().values()) {
      ObjectId objectId = ref.getPeeledObjectId();
      if (objectId == null)
        objectId = ref.getObjectId();
      add(objectId);
    }
    return this;
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

                  lastAddedFile = path;
                } else {
                  Repository subRepo = Git.open(
                      new File(repo.getWorkTree(), path))
                      .getRepository();
                  ObjectId subRepoHead = subRepo
                      .resolve(Constants.HEAD);
                  if (subRepoHead != null) {
                    entry.setObjectId(subRepoHead);
                    builder.add(entry);
                    lastAddedFile = path;
View Full Code Here

  }

  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) {
        // EOF on stateless RPC (aka smart HTTP) and non-shallow request
        // means the client asked for the updated shallow/unshallow data,
        // disconnected, and will try another request with actual want/have.
        // Don't report the EOF here, its a bug in the protocol that the client
        // just disconnects without sending an END.
        if (!biDirectionalPipe && depth > 0)
          return false;
        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());
            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) && requestPolicy != RequestPolicy.ANY) {
            if (notAdvertisedWants == null)
              notAdvertisedWants = new HashSet<RevObject>();
            notAdvertisedWants.add(obj);
          }

          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();
    }

    // If the client asked for non advertised object, check our policy.
    if (notAdvertisedWants != null && !notAdvertisedWants.isEmpty()) {
      switch (requestPolicy) {
      case ADVERTISED:
      default:
        throw new PackProtocolException(MessageFormat.format(
            JGitText.get().wantNotValid,
            notAdvertisedWants.iterator().next().name()));

      case REACHABLE_COMMIT:
        checkNotAdvertisedWants(notAdvertisedWants);
        break;

      case ANY:
        // Allow whatever was asked for.
        break;
      }
    }

    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;
    }

    preUploadHook.onEndNegotiateRound(this, wantAll, haveCnt, missCnt, sentReady);
    peerHas.clear();
View Full Code Here

        rw = ow;
      }

      if (options.contains(OPTION_INCLUDE_TAG) && refs != null) {
        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

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.