/** * A helper method where actual processing of the list of changes since the last refresh of the repository takes place * and the changes applied. * @throws IOException */ void processGitConfigChangesHelper(List<DiffEntry> changes) throws IOException { for (DiffEntry change : changes) { switch (change.getChangeType()) { case ADD: case MODIFY: addChange(change); break; case DELETE: removeChange(change); break; case RENAME: removeChange(change); addChange(change); break; default: throw new RuntimeException("Unsupported change type " + change.getChangeType()); } } // Done processing changes, so checkpoint this.gitRepo.moveCheckpointAndHashesForward(); }
private static boolean isRename(DiffEntry ent) { return ent.getChangeType() == ChangeType.RENAME || ent.getChangeType() == ChangeType.COPY; } }
private static boolean isRename(DiffEntry ent) { return ent.getChangeType() == ChangeType.RENAME || ent.getChangeType() == ChangeType.COPY; } }
private static boolean isRename(DiffEntry ent) { return ent.getChangeType() == RENAME || ent.getChangeType() == COPY; }
private boolean isAdd(List<DiffEntry> files) { String oldPath = ((FollowFilter) pathFilter).getPath(); for (DiffEntry ent : files) { if (ent.getChangeType() == ADD && ent.getNewPath().equals(oldPath)) return true; } return false; }
@Override public int compare(DiffEntry a, DiffEntry b) { int cmp = nameOf(a).compareTo(nameOf(b)); if (cmp == 0) cmp = sortOf(a.getChangeType()) - sortOf(b.getChangeType()); return cmp; }
private void breakModifies(ContentSource.Pair reader, ProgressMonitor pm) throws IOException, CancelledException { ArrayList<DiffEntry> newEntries = new ArrayList<>(entries.size()); pm.beginTask(JGitText.get().renamesBreakingModifies, entries.size()); for (int i = 0; i < entries.size(); i++) { DiffEntry e = entries.get(i); if (e.getChangeType() == ChangeType.MODIFY) { int score = calculateModifyScore(reader, e); if (score < breakScore) { List<DiffEntry> tmp = DiffEntry.breakModify(e); DiffEntry del = tmp.get(0); del.score = score; deleted.add(del); added.add(tmp.get(1)); } else { newEntries.add(e); } } else { newEntries.add(e); } advanceOrCancel(pm); } entries = newEntries; }
public static ArrayMemory valueOf(DiffEntry value) { ArrayMemory memory = new ArrayMemory(); memory.refOfIndex("oldId").assign(value.getOldId() == null ? Memory.NULL : valueOf(value.getOldId().toObjectId())); memory.refOfIndex("oldPath").assign(value.getOldPath()); memory.refOfIndex("oldMode").assign(value.getOldMode() == null ? Memory.NULL : StringMemory.valueOf(value.getOldMode().toString())); memory.refOfIndex("newId").assign(value.getNewId() == null ? Memory.NULL : valueOf(value.getNewId().toObjectId())); memory.refOfIndex("newPath").assign(value.getNewPath()); memory.refOfIndex("newMode").assign(value.getNewMode() == null ? Memory.NULL : StringMemory.valueOf(value.getNewMode().toString())); memory.refOfIndex("score").assign(value.getScore()); memory.refOfIndex("changeType").assign(value.getChangeType().name()); return memory; }
switch (entry.getChangeType()) { case ADD: added.add(entry);
private static void listDiff(Repository repository, Git git, String oldCommit, String newCommit) throws GitAPIException, IOException { final List<DiffEntry> diffs = git.diff() .setOldTree(prepareTreeParser(repository, oldCommit)) .setNewTree(prepareTreeParser(repository, newCommit)) .call(); System.out.println("Found: " + diffs.size() + " differences"); for (DiffEntry diff : diffs) { System.out.println("Diff: " + diff.getChangeType() + ": " + (diff.getOldPath().equals(diff.getNewPath()) ? diff.getNewPath() : diff.getOldPath() + " -> " + diff.getNewPath())); } }
private static void listDiff(Repository repository, Git git, String oldCommit, String newCommit) throws GitAPIException, IOException { final List<DiffEntry> diffs = git.diff() .setOldTree(prepareTreeParser(repository, oldCommit)) .setNewTree(prepareTreeParser(repository, newCommit)) .call(); System.out.println("Found: " + diffs.size() + " differences"); for (DiffEntry diff : diffs) { System.out.println("Diff: " + diff.getChangeType() + ": " + (diff.getOldPath().equals(diff.getNewPath()) ? diff.getNewPath() : diff.getOldPath() + " -> " + diff.getNewPath())); } }
private void formatHeader(ByteArrayOutputStream o, DiffEntry ent) throws IOException { final ChangeType type = ent.getChangeType(); final String oldp = ent.getOldPath(); final String newp = ent.getNewPath();
private void formatOldNewPaths(ByteArrayOutputStream o, DiffEntry ent) throws IOException { if (ent.oldId.equals(ent.newId)) return; final String oldp; final String newp; switch (ent.getChangeType()) { case ADD: oldp = DiffEntry.DEV_NULL; newp = quotePath(newPrefix + ent.getNewPath()); break; case DELETE: oldp = quotePath(oldPrefix + ent.getOldPath()); newp = DiffEntry.DEV_NULL; break; default: oldp = quotePath(oldPrefix + ent.getOldPath()); newp = quotePath(newPrefix + ent.getNewPath()); break; } o.write(encode("--- " + oldp + "\n")); //$NON-NLS-1$ //$NON-NLS-2$ o.write(encode("+++ " + newp + "\n")); //$NON-NLS-1$ //$NON-NLS-2$ }
private static boolean isRename(DiffEntry ent) { return ent.getChangeType() == ChangeType.RENAME || ent.getChangeType() == ChangeType.COPY; } }
type = PatchType.UNIFIED; switch (ent.getChangeType()) { case RENAME: case COPY:
private String statusOf(DiffEntry d) { switch (d.getChangeType()) { case ADD: return "A"; case MODIFY: return "M"; case DELETE: return "D"; case RENAME: return "R"+d.getScore(); case COPY: return "C"+d.getScore(); default: throw new AssertionError("Unexpected change type: "+d.getChangeType()); } }
@JavascriptInterface public String getChangeType(int index) { DiffEntry diff = mDiffEntries.get(index); DiffEntry.ChangeType ct = diff.getChangeType(); return ct.toString(); }
@JavascriptInterface public String getChangeType(int index) { DiffEntry diff = mDiffEntries.get(index); DiffEntry.ChangeType ct = diff.getChangeType(); return ct.toString(); }
@Override public int compare(DiffEntry a, DiffEntry b) { int cmp = nameOf(a).compareTo(nameOf(b)); if (cmp == 0) cmp = sortOf(a.getChangeType()) - sortOf(b.getChangeType()); return cmp; }
/** * @return the old path in case of a delete, the new path otherwise, but * never null or <code>/dev/null</code> * @see #getNewPath() * @see #getOldPath() */ public String getPath() { if (ChangeType.DELETE.equals(diffEntry.getChangeType())) return diffEntry.getOldPath(); return diffEntry.getNewPath(); }