diff options
| author | Robin Stocker | 2011-06-12 03:15:47 +0000 |
|---|---|---|
| committer | Kevin Sawicki | 2011-06-12 03:15:47 +0000 |
| commit | 66f2a8b8662ce358c1d361476cdc28aaffd9119c (patch) | |
| tree | ad297bf7954f998d8e7509fec6692158c48a0943 | |
| parent | 4d4131902a0b30ea7890ec7a88476de60aed8166 (diff) | |
| download | egit-66f2a8b8662ce358c1d361476cdc28aaffd9119c.tar.gz egit-66f2a8b8662ce358c1d361476cdc28aaffd9119c.tar.xz egit-66f2a8b8662ce358c1d361476cdc28aaffd9119c.zip | |
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.java | 17 |
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 9202c1ab06..01be134039 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; } } |
