Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.ObjectId


  public void load() throws IOException, ConfigInvalidException {
    final FileSnapshot oldSnapshot = snapshot;
    final FileSnapshot newSnapshot = FileSnapshot.save(getFile());
    try {
      final byte[] in = IO.readFully(getFile());
      final ObjectId newHash = hash(in);
      if (hash.equals(newHash)) {
        if (oldSnapshot.equals(newSnapshot))
          oldSnapshot.setClean(newSnapshot);
        else
          snapshot = newSnapshot;
View Full Code Here


          if (entries == null)
            continue;
          for (String e : entries) {
            if (e.length() != Constants.OBJECT_ID_STRING_LENGTH - 2)
              continue;
            ObjectId id;
            try {
              id = ObjectId.fromString(d + e);
            } catch (IllegalArgumentException notAnObject) {
              // ignoring the file that does not represent loose
              // object
View Full Code Here

            if (fName.length() != Constants.OBJECT_ID_STRING_LENGTH - 2)
              continue;
            if (f.lastModified() >= expireDate)
              continue;
            try {
              ObjectId id = ObjectId.fromString(d + fName);
              if (objectsToKeep.contains(id))
                continue;
              if (indexObjects == null)
                indexObjects = listNonHEADIndexObjects();
              if (indexObjects.contains(id))
View Full Code Here

    Set<ObjectId> ret = new HashSet<ObjectId>();
    for (ReflogEntry e : rlEntries) {
      if (e.getWho().getWhen().getTime() < minTime)
        break;
      ret.add(e.getNewId());
      ObjectId oldId = e.getOldId();
      if (oldId != null && !ObjectId.zeroId().equals(oldId))
        ret.add(oldId);
    }
    return ret;
  }
View Full Code Here

      return Collections.emptySet();
    }
    TreeWalk treeWalk = new TreeWalk(repo);
    try {
      treeWalk.addTree(new DirCacheIterator(repo.readDirCache()));
      ObjectId headID = repo.resolve(Constants.HEAD);
      if (headID != null) {
        revWalk = new RevWalk(repo);
        treeWalk.addTree(revWalk.parseTree(headID));
        revWalk.dispose();
        revWalk = null;
      }

      treeWalk.setFilter(TreeFilter.ANY_DIFF);
      treeWalk.setRecursive(true);
      Set<ObjectId> ret = new HashSet<ObjectId>();

      while (treeWalk.next()) {
        ObjectId objectId = treeWalk.getObjectId(0);
          switch (treeWalk.getRawMode(0) & FileMode.TYPE_MASK) {
            case FileMode.TYPE_MISSING:
            case FileMode.TYPE_GITLINK:
              continue;
            case FileMode.TYPE_TREE:
            case FileMode.TYPE_FILE:
            case FileMode.TYPE_SYMLINK:
              ret.add(objectId);
              continue;
            default:
          throw new IOException(MessageFormat.format(
              JGitText.get().corruptObjectInvalidMode3, String
                  .format("%o", Integer.valueOf(treeWalk
                      .getRawMode(0)),
                      (objectId == null) ? "null"
                          : objectId.name(), treeWalk
                      .getPathString(), repo
                      .getIndexFile())));
          }
        }
      return ret;
View Full Code Here

  }

  @Override
  public ObjectId insert(int type, byte[] data, int off, int len)
      throws IOException {
    ObjectId id = idFor(type, data, off, len);
    if (db.has(id)) {
      return id;
    } else {
      File tmp = toTemp(type, data, off, len);
      return insertOneObject(tmp, id);
View Full Code Here

      return insert(type, buf, 0, actLen);

    } else {
      MessageDigest md = digest();
      File tmp = toTemp(md, type, len, is);
      ObjectId id = ObjectId.fromRaw(md.digest());
      return insertOneObject(tmp, id);
    }
  }
View Full Code Here

    if (entries != null) {
      for (String e : entries) {
        if (e.length() != Constants.OBJECT_ID_STRING_LENGTH - 2)
          continue;
        try {
          ObjectId entId = ObjectId.fromString(fanOut + e);
          if (id.prefixCompare(entId) == 0)
            matches.add(entId);
        } catch (IllegalArgumentException notId) {
          continue;
        }
View Full Code Here

      return zeroid;
    }
    if (submoduleRepo == null)
      return zeroid;

    final ObjectId head;
    try {
      head = submoduleRepo.resolve(Constants.HEAD);
    } catch (IOException exception) {
      return zeroid;
    } finally {
      submoduleRepo.close();
    }
    if (head == null)
      return zeroid;
    final byte[] id = new byte[Constants.OBJECT_ID_LENGTH];
    head.copyRawTo(id, 0);
    return id;
  }
View Full Code Here

      newTag.setMessage(message);
      newTag.setTagger(tagger);

      // if no id is set, we should attempt to use HEAD
      if (id == null) {
        ObjectId objectId = repo.resolve(Constants.HEAD + "^{commit}");
        if (objectId == null)
          throw new NoHeadException(
              JGitText.get().tagOnRepoWithoutHEADCurrentlyNotSupported);

        newTag.setObjectId(objectId, Constants.OBJ_COMMIT);
      } else {
        newTag.setObjectId(id);
      }

      // write the tag object
      ObjectInserter inserter = repo.newObjectInserter();
      try {
        ObjectId tagId = inserter.insert(newTag);
        inserter.flush();

        RevWalk revWalk = new RevWalk(repo);
        try {
          String refName = Constants.R_TAGS + newTag.getTag();
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.