Fix combined diffs on merge commits
A bad automated refactoring led us to try and obtain the EditList for a combined diff patch script. These scripts don't have any edits, because there is more than old image involved in each range. Fix the code to rule out a combined diff format script and do not access its EditList when creating the cache entry. Change-Id: Idc81370ffb4b1c7bf65c525043bf6b21314a01cf Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -188,10 +188,6 @@ public class PatchListCacheImpl implements PatchListCache {
|
||||
|
||||
private static PatchListEntry newEntry(Repository repo, RevTree aTree,
|
||||
RevTree bTree, FileHeader fileHeader) throws IOException {
|
||||
if (fileHeader.getHunks().isEmpty()) {
|
||||
return new PatchListEntry(fileHeader, Collections.<Edit> emptyList());
|
||||
}
|
||||
|
||||
final FileMode oldMode = fileHeader.getOldMode();
|
||||
final FileMode newMode = fileHeader.getNewMode();
|
||||
|
||||
@@ -199,17 +195,17 @@ public class PatchListCacheImpl implements PatchListCache {
|
||||
return new PatchListEntry(fileHeader, Collections.<Edit> emptyList());
|
||||
}
|
||||
|
||||
List<Edit> edits = fileHeader.toEditList();
|
||||
if (aTree == null // want combined diff
|
||||
|| fileHeader.getPatchType() != PatchType.UNIFIED
|
||||
|| fileHeader.getHunks().isEmpty()) {
|
||||
return new PatchListEntry(fileHeader, Collections.<Edit> emptyList());
|
||||
}
|
||||
|
||||
// Bypass the longer task of looking for replacement edits if
|
||||
// there cannot be a replacement within plain text.
|
||||
//
|
||||
if (aTree == null /* want combined diff */) {
|
||||
return new PatchListEntry(fileHeader, edits);
|
||||
}
|
||||
if (fileHeader.getPatchType() != PatchType.UNIFIED || edits.isEmpty()) {
|
||||
return new PatchListEntry(fileHeader, edits);
|
||||
List<Edit> edits = fileHeader.toEditList();
|
||||
if (edits.isEmpty()) {
|
||||
return new PatchListEntry(fileHeader, Collections.<Edit> emptyList());
|
||||
}
|
||||
|
||||
switch (fileHeader.getChangeType()) {
|
||||
case ADD:
|
||||
case DELETE:
|
||||
|
Reference in New Issue
Block a user