Browse Source

TreeRevFilter: Refresh code to latest coding standards

Use brackets in all "if" statements and remove the "final" from local
variables and method arguments.

https://wiki.eclipse.org/EGit/Contributor_Guide#Coding_standards

Change-Id: I185f3112848fc1218cd7adb9828488f03fa4ddfc
Signed-off-by: Ivan Frade <ifrade@google.com>
stable-5.5
Ivan Frade 5 years ago
parent
commit
848d9f0d71
  1. 41
      org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java

41
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/TreeRevFilter.java

@ -116,8 +116,7 @@ public class TreeRevFilter extends RevFilter {
* @param rewriteFlag * @param rewriteFlag
* flag to color commits to be removed from the simplified DAT. * flag to color commits to be removed from the simplified DAT.
*/ */
TreeRevFilter(final RevWalk walker, final TreeFilter t, TreeRevFilter(RevWalk walker, TreeFilter t, int rewriteFlag) {
final int rewriteFlag) {
pathFilter = new TreeWalk(walker.reader); pathFilter = new TreeWalk(walker.reader);
pathFilter.setFilter(t); pathFilter.setFilter(t);
pathFilter.setRecursive(t.shouldBeRecursive()); pathFilter.setRecursive(t.shouldBeRecursive());
@ -137,14 +136,15 @@ public class TreeRevFilter extends RevFilter {
IncorrectObjectTypeException, IOException { IncorrectObjectTypeException, IOException {
// Reset the tree filter to scan this commit and parents. // Reset the tree filter to scan this commit and parents.
// //
final RevCommit[] pList = c.parents; RevCommit[] pList = c.parents;
final int nParents = pList.length; int nParents = pList.length;
final TreeWalk tw = pathFilter; TreeWalk tw = pathFilter;
final ObjectId[] trees = new ObjectId[nParents + 1]; ObjectId[] trees = new ObjectId[nParents + 1];
for (int i = 0; i < nParents; i++) { for (int i = 0; i < nParents; i++) {
final RevCommit p = c.parents[i]; RevCommit p = c.parents[i];
if ((p.flags & PARSED) == 0) if ((p.flags & PARSED) == 0) {
p.parseHeaders(walker); p.parseHeaders(walker);
}
trees[i] = p.getTree(); trees[i] = p.getTree();
} }
trees[nParents] = c.getTree(); trees[nParents] = c.getTree();
@ -156,10 +156,11 @@ public class TreeRevFilter extends RevFilter {
int chgs = 0, adds = 0; int chgs = 0, adds = 0;
while (tw.next()) { while (tw.next()) {
chgs++; chgs++;
if (tw.getRawMode(0) == 0 && tw.getRawMode(1) != 0) if (tw.getRawMode(0) == 0 && tw.getRawMode(1) != 0) {
adds++; adds++;
else } else {
break; // no point in looking at this further. break; // no point in looking at this further.
}
} }
if (chgs == 0) { if (chgs == 0) {
@ -185,8 +186,9 @@ public class TreeRevFilter extends RevFilter {
// We have no parents to compare against. Consider us to be // We have no parents to compare against. Consider us to be
// REWRITE only if we have no paths matching our filter. // REWRITE only if we have no paths matching our filter.
// //
if (tw.next()) if (tw.next()) {
return true; return true;
}
c.flags |= rewriteFlag; c.flags |= rewriteFlag;
return false; return false;
} }
@ -196,18 +198,19 @@ public class TreeRevFilter extends RevFilter {
// it does not contribute changes to us. Such a parent may be an // it does not contribute changes to us. Such a parent may be an
// uninteresting side branch. // uninteresting side branch.
// //
final int[] chgs = new int[nParents]; int[] chgs = new int[nParents];
final int[] adds = new int[nParents]; int[] adds = new int[nParents];
while (tw.next()) { while (tw.next()) {
final int myMode = tw.getRawMode(nParents); int myMode = tw.getRawMode(nParents);
for (int i = 0; i < nParents; i++) { for (int i = 0; i < nParents; i++) {
final int pMode = tw.getRawMode(i); int pMode = tw.getRawMode(i);
if (myMode == pMode && tw.idEqual(i, nParents)) if (myMode == pMode && tw.idEqual(i, nParents)) {
continue; continue;
}
chgs[i]++; chgs[i]++;
if (pMode == 0 && myMode != 0) if (pMode == 0 && myMode != 0) {
adds[i]++; adds[i]++;
}
} }
} }
@ -220,7 +223,7 @@ public class TreeRevFilter extends RevFilter {
// parent commit. // parent commit.
// //
final RevCommit p = pList[i]; RevCommit p = pList[i];
if ((p.flags & UNINTERESTING) != 0) { if ((p.flags & UNINTERESTING) != 0) {
// This parent was marked as not interesting by the // This parent was marked as not interesting by the
// application. We should look for another parent // application. We should look for another parent

Loading…
Cancel
Save