aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2011-06-11 23:15:47 -0400
committerKevin Sawicki2011-06-11 23:15:47 -0400
commit66f2a8b8662ce358c1d361476cdc28aaffd9119c (patch)
treead297bf7954f998d8e7509fec6692158c48a0943
parent4d4131902a0b30ea7890ec7a88476de60aed8166 (diff)
downloadegit-66f2a8b8662ce358c1d361476cdc28aaffd9119c.zip
egit-66f2a8b8662ce358c1d361476cdc28aaffd9119c.tar.gz
egit-66f2a8b8662ce358c1d361476cdc28aaffd9119c.tar.xz
Fix "Open in Commit Viewer" from resource-filtered History view
When looking at the history of a single resource in the History view and then opening a commit in the Commit Viewer, the Files section would show invalid changes. The problem was that the parent of the RevCommit was set to the previous commit for the same resource and therefore the diff included all changes between those commits (not only to the previous one). We fix this by re-parsing the commit with a clean RevWalk before showing it. Change-Id: I24dbad00575e4c6b38da72c7b6ea6b90b30c5b33 Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Kevin Sawicki <kevin@github.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/OpenInCommitViewerHandler.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/OpenInCommitViewerHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/OpenInCommitViewerHandler.java
index 9202c1a..01be134 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/OpenInCommitViewerHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/OpenInCommitViewerHandler.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.history.command;
+import java.io.IOException;
+
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.egit.ui.Activator;
@@ -17,6 +19,7 @@ import org.eclipse.egit.ui.internal.commit.CommitEditor;
import org.eclipse.egit.ui.internal.commit.RepositoryCommit;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.ui.PartInitException;
/**
@@ -26,14 +29,22 @@ public class OpenInCommitViewerHandler extends AbstractHistoryCommandHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
Repository repository = getRepository(event);
- if (repository != null)
+ if (repository != null) {
+ RevWalk revWalk = new RevWalk(repository);
for (Object selected : getSelection(getPage()).toList())
try {
- CommitEditor.open(new RepositoryCommit(repository,
- (RevCommit) selected));
+ RevCommit selectedCommit = (RevCommit) selected;
+
+ // Re-parse commit to clear effects of TreeFilter
+ RevCommit reparsedCommit = revWalk.parseCommit(selectedCommit.getId());
+
+ CommitEditor.open(new RepositoryCommit(repository, reparsedCommit));
+ } catch (IOException e) {
+ Activator.showError("Error opening commit viewer", e); //$NON-NLS-1$
} catch (PartInitException e) {
Activator.showError("Error opening commit viewer", e); //$NON-NLS-1$
}
+ }
return null;
}
}