Package org.eclipse.jgit.diff

Examples of org.eclipse.jgit.diff.DiffEntry


  }

  private Diff calculateDiffToParent(RevCommit parentCommit) {
    ObjectReader reader = repository.newObjectReader();
    try {
      DiffEntry diffEntry = CompareCoreUtils.getChangeDiffEntry(
          repository, sourcePath, commit, parentCommit, reader);
      if (diffEntry == null)
        return null;

      RawText oldText = readText(diffEntry.getOldId(), reader);
      RawText newText = readText(diffEntry.getNewId(), reader);

      StoredConfig config = repository.getConfig();
      DiffAlgorithm diffAlgorithm = DiffAlgorithm.getAlgorithm(config
          .getEnum(ConfigConstants.CONFIG_DIFF_SECTION, null,
              ConfigConstants.CONFIG_KEY_ALGORITHM,
              SupportedAlgorithm.HISTOGRAM));

      EditList editList = diffAlgorithm.diff(RawTextComparator.DEFAULT,
          oldText, newText);

      return new Diff(diffEntry.getOldPath(), oldText, newText, editList);
    } catch (IOException e) {
      return null;
    } finally {
      reader.release();
    }
View Full Code Here


          org.eclipse.jgit.lib.NullProgressMonitor.INSTANCE);
      for (DiffEntry m : renames) {
        final FileDiff d = new FileDiff(commit, m);
        r.add(d);
        for (Iterator<DiffEntry> i = xentries.iterator(); i.hasNext();) {
          DiffEntry n = i.next();
          if (m.getOldPath().equals(n.getOldPath()))
            i.remove();
          else if (m.getNewPath().equals(n.getNewPath()))
            i.remove();
        }
      }
      for (DiffEntry m : xentries) {
        final FileDiff d = new FileDiff(commit, m);
View Full Code Here

    Repository repo = CookbookHelper.openJGitCookbookRepository();

    // Diff README.md between two commits. The file is named README.md in
    // the new commit (5a10bd6e), but was named "jgit-cookbook README.md" in
    // the old commit (2e1d65e4).
    DiffEntry diff = diffFile(repo,
      "2e1d65e4cf6c5e267e109aa20fd68ae119fa5ec9",
      "5a10bd6ee431e362facb03cfe763b9a3d9dfd02d",
      "README.md");

    // Display the diff.
View Full Code Here

              // ignore massive merges / refactorings
              continue;
            }
           
            for (Object obj : diffs) {
              DiffEntry diff = (DiffEntry) obj;

              String file = diff.getNewPath().toLowerCase();

              ChangeType mode = diff.getChangeType();
              if (ChangeType.DELETE.equals(mode) ||
                ChangeType.RENAME.equals(mode) ||
                ChangeType.COPY.equals(mode)) {
                // since the aim is to find who was the lead on a project
                // just count things that look like real work, not moving
View Full Code Here

    }

    if (n.sourceCommit == null)
      return result(n);

    DiffEntry r = findRename(parent, n.sourceCommit, n.sourcePath);
    if (r == null)
      return result(n);

    if (0 == r.getOldId().prefixCompare(n.sourceBlob)) {
      // A 100% rename without any content change can also
      // skip directly to the parent.
      n.sourceCommit = parent;
      n.sourcePath = PathFilter.create(r.getOldPath());
      push(n);
      return false;
    }

    Candidate next = n.create(parent, PathFilter.create(r.getOldPath()));
    next.sourceBlob = r.getOldId().toObjectId();
    next.renameScore = r.getScore();
    next.loadText(reader);
    return split(next, n);
  }
View Full Code Here

        if (parent.has(SEEN))
          continue;
        if (ids != null && ids[pIdx] != null)
          continue;

        DiffEntry r = findRename(parent, n.sourceCommit, n.sourcePath);
        if (r == null)
          continue;

        if (n instanceof ReverseCandidate) {
          if (ids == null)
            ids = new ObjectId[pCnt];
          ids[pCnt] = r.getOldId().toObjectId();
        } else if (0 == r.getOldId().prefixCompare(n.sourceBlob)) {
          // A 100% rename without any content change can also
          // skip directly to the parent. Note this bypasses an
          // earlier parent that had the path (above) but did not
          // have an exact content match. For performance reasons
          // we choose to follow the one parent over trying to do
          // possibly both parents.
          n.sourceCommit = parent;
          n.sourcePath = PathFilter.create(r.getOldPath());
          push(n);
          return false;
        }

        renames[pIdx] = r;
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.diff.DiffEntry

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.