diff --git a/plugins/git4idea/src/git4idea/history/GitChangesParser.java b/plugins/git4idea/src/git4idea/history/GitChangesParser.java index 30870414402e..09deb4319087 100644 --- a/plugins/git4idea/src/git4idea/history/GitChangesParser.java +++ b/plugins/git4idea/src/git4idea/history/GitChangesParser.java @@ -23,7 +23,6 @@ import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.ContentRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.containers.ContainerUtil; import git4idea.GitContentRevision; import git4idea.GitRevisionNumber; import org.jetbrains.annotations.NotNull; @@ -43,22 +42,25 @@ public class GitChangesParser { @NotNull Date date, @NotNull List parentsHashes) throws VcsException { GitRevisionNumber thisRevision = new GitRevisionNumber(hash, date); - List parentRevisions = ContainerUtil.map(parentsHashes, GitRevisionNumber::new); + GitRevisionNumber parentRevision = parentsHashes.isEmpty() ? null : new GitRevisionNumber(parentsHashes.get(0)); List result = new ArrayList<>(); for (GitLogStatusInfo statusInfo : statusInfos) { - result.add(parseChange(project, root, parentRevisions, statusInfo, thisRevision)); + result.add(parseChange(project, root, thisRevision, parentRevision, statusInfo)); } return result; } - private static Change parseChange(final Project project, final VirtualFile vcsRoot, final List parentRevisions, - final GitLogStatusInfo statusInfo, final VcsRevisionNumber thisRevision) throws VcsException { + @NotNull + private static Change parseChange(@NotNull Project project, + @NotNull VirtualFile vcsRoot, + @NotNull VcsRevisionNumber thisRevision, + @Nullable VcsRevisionNumber parentRevision, + @NotNull GitLogStatusInfo statusInfo) throws VcsException { final ContentRevision before; final ContentRevision after; FileStatus status = null; final String path = statusInfo.getFirstPath(); - @Nullable GitRevisionNumber firstParent = parentRevisions.isEmpty() ? null : parentRevisions.get(0); switch (statusInfo.getType()) { case ADDED: @@ -73,13 +75,13 @@ public class GitChangesParser { status = FileStatus.MODIFIED; } final FilePath filePath = GitContentRevision.createPath(vcsRoot, path, true, true); - before = GitContentRevision.createRevision(vcsRoot, path, firstParent, project, false, true); + before = GitContentRevision.createRevision(vcsRoot, path, parentRevision, project, false, true); after = GitContentRevision.createRevision(filePath, thisRevision, project, null); break; case DELETED: status = FileStatus.DELETED; final FilePath filePathDeleted = GitContentRevision.createPath(vcsRoot, path, true, true); - before = GitContentRevision.createRevision(filePathDeleted, firstParent, project, null); + before = GitContentRevision.createRevision(filePathDeleted, parentRevision, project, null); after = null; break; case COPIED: @@ -88,13 +90,13 @@ public class GitChangesParser { String secondPath = statusInfo.getSecondPath(); final FilePath filePathAfterRename = GitContentRevision.createPath(vcsRoot, secondPath == null ? path : secondPath, false, true); - before = GitContentRevision.createRevision(vcsRoot, path, firstParent, project, true, true); + before = GitContentRevision.createRevision(vcsRoot, path, parentRevision, project, true, true); after = GitContentRevision.createRevision(filePathAfterRename, thisRevision, project, null); break; case TYPE_CHANGED: status = FileStatus.MODIFIED; final FilePath filePath2 = GitContentRevision.createPath(vcsRoot, path, true, true); - before = GitContentRevision.createRevision(vcsRoot, path, firstParent, project, false, true); + before = GitContentRevision.createRevision(vcsRoot, path, parentRevision, project, false, true); after = GitContentRevision.createRevision(filePath2, thisRevision, project, null); break; default: