Package org.eclipse.jgit.errors

Examples of org.eclipse.jgit.errors.PackProtocolException


    if (statelessRPC && multiAck != MultiAck.DETAILED) {
      // Our stateless RPC implementation relies upon the detailed
      // ACK status to tell us common objects for reuse in future
      // requests.  If its not enabled, we can't talk to the peer.
      //
      throw new PackProtocolException(uri, MessageFormat.format(
          JGitText.get().statelessRPCRequiresOptionToBeEnabled,
          OPTION_MULTI_ACK_DETAILED));
    }

    return line.toString();
View Full Code Here


      }
      return avail;
    }

    private PackProtocolException outOfOrderAdvertisement(final String n) {
      return new PackProtocolException(MessageFormat.format(JGitText.get().advertisementOfCameBefore, n, n));
    }
View Full Code Here

    private PackProtocolException outOfOrderAdvertisement(final String n) {
      return new PackProtocolException(MessageFormat.format(JGitText.get().advertisementOfCameBefore, n, n));
    }

    private PackProtocolException invalidAdvertisement(final String n) {
      return new PackProtocolException(MessageFormat.format(JGitText.get().invalidAdvertisementOf, n));
    }
View Full Code Here

    private PackProtocolException invalidAdvertisement(final String n) {
      return new PackProtocolException(MessageFormat.format(JGitText.get().invalidAdvertisementOf, n));
    }

    private PackProtocolException duplicateAdvertisement(final String n) {
      return new PackProtocolException(MessageFormat.format(JGitText.get().duplicateAdvertisementsOf, n));
    }
View Full Code Here

  private void readStatusReport(final Map<String, RemoteRefUpdate> refUpdates)
      throws IOException {
    final String unpackLine = readStringLongTimeout();
    if (!unpackLine.startsWith("unpack "))
      throw new PackProtocolException(uri, MessageFormat.format(JGitText.get().unexpectedReportLine, unpackLine));
    final String unpackStatus = unpackLine.substring("unpack ".length());
    if (!unpackStatus.equals("ok"))
      throw new TransportException(uri, MessageFormat.format(
          JGitText.get().errorOccurredDuringUnpackingOnTheRemoteEnd, unpackStatus));

    String refLine;
    while ((refLine = pckIn.readString()) != PacketLineIn.END) {
      boolean ok = false;
      int refNameEnd = -1;
      if (refLine.startsWith("ok ")) {
        ok = true;
        refNameEnd = refLine.length();
      } else if (refLine.startsWith("ng ")) {
        ok = false;
        refNameEnd = refLine.indexOf(" ", 3);
      }
      if (refNameEnd == -1)
        throw new PackProtocolException(MessageFormat.format(JGitText.get().unexpectedReportLine2
            , uri, refLine));
      final String refName = refLine.substring(3, refNameEnd);
      final String message = (ok ? null : refLine
          .substring(refNameEnd + 1));

      final RemoteRefUpdate rru = refUpdates.get(refName);
      if (rru == null)
        throw new PackProtocolException(MessageFormat.format(JGitText.get().unexpectedRefReport, uri, refName));
      if (ok) {
        rru.setStatus(Status.OK);
      } else {
        rru.setStatus(Status.REJECTED_OTHER_REASON);
        rru.setMessage(message);
      }
    }
    for (final RemoteRefUpdate rru : refUpdates.values()) {
      if (rru.getStatus() == Status.AWAITING_REPORT)
        throw new PackProtocolException(MessageFormat.format(
            JGitText.get().expectedReportForRefNotReceived , uri, rru.getRemoteName()));
    }
  }
View Full Code Here

      }

      if (line.length() < 83) {
        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);
View Full Code Here

        clientShallowCommits.add(ObjectId.fromString(line.substring(8)));
        continue;
      }

      if (!line.startsWith("want ") || line.length() < 45)
        throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedGot, "want", line));

      if (isFirst && line.length() > 45) {
        String opt = line.substring(45);
        if (opt.startsWith(" "))
          opt = opt.substring(1);
View Full Code Here

          pckOut.writeString("ACK " + last.name() + "\n");

        return true;

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

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

    // If the requested commit is merged into an advertised branch
    // it will be marked UNINTERESTING and no commits return.

    for (RevObject o : notAdvertisedWants) {
      if (!(o instanceof RevCommit)) {
        throw new PackProtocolException(MessageFormat.format(
            JGitText.get().wantNotValid,
            notAdvertisedWants.iterator().next().name()));
      }
      walk.markStart((RevCommit) o);
    }

    for (ObjectId id : advertised) {
      try {
        walk.markUninteresting(walk.parseCommit(id));
      } catch (IncorrectObjectTypeException notCommit) {
        continue;
      }
    }

    RevCommit bad = walk.next();
    if (bad != null) {
      throw new PackProtocolException(MessageFormat.format(
          JGitText.get().wantNotValid,
          bad.name()));
    }
    walk.reset();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.errors.PackProtocolException

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.