mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] Fix NPE: use before revision if there is no after revision
Can happen if the file was deleted in the selected commit.
This commit is contained in:
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.changes.committed.DecoratorManager;
|
||||
import com.intellij.openapi.vcs.changes.committed.VcsCommittedListsZipper;
|
||||
import com.intellij.openapi.vcs.changes.committed.VcsCommittedViewAuxiliary;
|
||||
@@ -197,7 +198,14 @@ public class GitCommittedChangeListProvider implements CommittedChangesProvider<
|
||||
|
||||
final Collection<Change> changes = commit.getChanges();
|
||||
if (changes.size() == 1) {
|
||||
return Pair.create(commit, changes.iterator().next().getAfterRevision().getFile());
|
||||
Change change = changes.iterator().next();
|
||||
ContentRevision revision = change.getAfterRevision();
|
||||
if (revision == null) {
|
||||
revision = change.getBeforeRevision();
|
||||
}
|
||||
assert revision != null : "Revision can't be null in " + change;
|
||||
FilePath filePathInRevision = revision.getFile();
|
||||
return Pair.create(commit, filePathInRevision);
|
||||
}
|
||||
for (Change change : changes) {
|
||||
if (change.getAfterRevision() != null && FileUtil.filesEqual(filePath.getIOFile(), change.getAfterRevision().getFile().getIOFile())) {
|
||||
|
||||
Reference in New Issue
Block a user