PatchListLoader: Fix againstParent computation
When a commit is compared against its parent, we want to show the complete commit message as new in the diff screen (diffing the commit message of the viewed commit with the commit message of the parent commit does not make sense). To detect this case PatchListLoader sets the againstParent flag. Until recently we only supported comparing commits against the first parent and hence the againstParent flag was only set if a comparison against the first parent was done. Consider all parents now. Change-Id: I29f2cae6f302cc173aa4bb6b3081f4f894007780 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -35,7 +35,7 @@ import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PatchListKey implements Serializable {
|
||||
public static final long serialVersionUID = 21L;
|
||||
public static final long serialVersionUID = 22L;
|
||||
|
||||
public static final BiMap<Whitespace, Character> WHITESPACE_TYPES = ImmutableBiMap.of(
|
||||
Whitespace.IGNORE_NONE, 'N',
|
||||
|
||||
@@ -162,8 +162,7 @@ public class PatchListLoader implements Callable<PatchList> {
|
||||
return new PatchList(a, b, true, entries);
|
||||
}
|
||||
|
||||
boolean againstParent =
|
||||
b.getParentCount() > 0 && b.getParent(0).equals(a);
|
||||
boolean againstParent = isAgainstParent(a, b);
|
||||
|
||||
RevCommit aCommit = a instanceof RevCommit ? (RevCommit) a : null;
|
||||
RevTree aTree = rw.parseTree(a);
|
||||
@@ -214,6 +213,16 @@ public class PatchListLoader implements Callable<PatchList> {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAgainstParent(RevObject a, RevCommit b) {
|
||||
for (int i = 0; i < b.getParentCount(); i++) {
|
||||
if (b.getParent(i).equals(a)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static long getFileSize(ObjectReader reader,
|
||||
FileMode mode, String path, RevTree t) throws IOException {
|
||||
if (!isBlob(mode)) {
|
||||
|
||||
Reference in New Issue
Block a user