[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:
Kirill Likhodedov
2014-07-01 19:26:54 +04:00
parent 07e5395963
commit 2860b4df88
@@ -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())) {