From b909e10a059f8916c2fbf7337948e5d9ee8515f8 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Wed, 12 Jul 2017 17:28:09 +0300 Subject: [PATCH] [git] method parse accepts specific parent revision, not list of all parents --- plugins/git4idea/src/git4idea/GitCommit.java | 14 ++++++++------ .../src/git4idea/history/GitChangesParser.java | 4 ++-- .../src/git4idea/history/GitLogRecord.java | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/plugins/git4idea/src/git4idea/GitCommit.java b/plugins/git4idea/src/git4idea/GitCommit.java index 2696a90bf7ff..9890768d49b8 100644 --- a/plugins/git4idea/src/git4idea/GitCommit.java +++ b/plugins/git4idea/src/git4idea/GitCommit.java @@ -178,7 +178,7 @@ public final class GitCommit extends VcsCommitMetadataImpl implements VcsFullCom @NotNull private ParsedChanges parseChanges() throws VcsException { - List mergedChanges = parseStatusInfo(getMergedStatusInfo(), ContainerUtil.map(getParents(), Hash::asString)); + List mergedChanges = parseStatusInfo(getMergedStatusInfo(), 0); List> changes = computeChanges(mergedChanges); ParsedChanges parsedChanges = new ParsedChanges(mergedChanges, changes); myChanges.compareAndSet(this, parsedChanges); @@ -230,17 +230,19 @@ public final class GitCommit extends VcsCommitMetadataImpl implements VcsFullCom else { List> changes = ContainerUtil.newArrayListWithCapacity(myChangesOutput.size()); for (int i = 0; i < myChangesOutput.size(); i++) { - List statusInfos = myChangesOutput.get(i); - changes.add(parseStatusInfo(statusInfos, Collections.singletonList(getParents().get(i).asString()))); + changes.add(parseStatusInfo(myChangesOutput.get(i), i)); } return changes; } } @NotNull - private List parseStatusInfo(@NotNull List changes, - @NotNull List parentHashes) throws VcsException { - return GitChangesParser.parse(myProject, getRoot(), changes, getId().asString(), new Date(getCommitTime()), parentHashes); + private List parseStatusInfo(@NotNull List changes, int parentIndex) throws VcsException { + String parentHash = null; + if (parentIndex < getParents().size()) { + parentHash = getParents().get(parentIndex).asString(); + } + return GitChangesParser.parse(myProject, getRoot(), changes, getId().asString(), new Date(getCommitTime()), parentHash); } /* diff --git a/plugins/git4idea/src/git4idea/history/GitChangesParser.java b/plugins/git4idea/src/git4idea/history/GitChangesParser.java index 09deb4319087..9c4da8fb4a04 100644 --- a/plugins/git4idea/src/git4idea/history/GitChangesParser.java +++ b/plugins/git4idea/src/git4idea/history/GitChangesParser.java @@ -40,9 +40,9 @@ public class GitChangesParser { @NotNull List statusInfos, @NotNull String hash, @NotNull Date date, - @NotNull List parentsHashes) throws VcsException { + @Nullable String parentsHash) throws VcsException { GitRevisionNumber thisRevision = new GitRevisionNumber(hash, date); - GitRevisionNumber parentRevision = parentsHashes.isEmpty() ? null : new GitRevisionNumber(parentsHashes.get(0)); + GitRevisionNumber parentRevision = parentsHash == null ? null : new GitRevisionNumber(parentsHash); List result = new ArrayList<>(); for (GitLogStatusInfo statusInfo : statusInfos) { diff --git a/plugins/git4idea/src/git4idea/history/GitLogRecord.java b/plugins/git4idea/src/git4idea/history/GitLogRecord.java index b9cd6bb3e241..7c0b119af8d9 100644 --- a/plugins/git4idea/src/git4idea/history/GitLogRecord.java +++ b/plugins/git4idea/src/git4idea/history/GitLogRecord.java @@ -256,7 +256,8 @@ class GitLogRecord { @NotNull public List parseChanges(@NotNull Project project, @NotNull VirtualFile vcsRoot) throws VcsException { - return GitChangesParser.parse(project, vcsRoot, myStatusInfo, getHash(), getDate(), Arrays.asList(getParentsHashes())); + String[] hashes = getParentsHashes(); + return GitChangesParser.parse(project, vcsRoot, myStatusInfo, getHash(), getDate(), hashes.length == 0 ? null : hashes[0]); } /**