/*******************************************************************************
 *  Copyright (c) 2011 GitHub Inc.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 *
 *  Contributors:
 *    Kevin Sawicki (GitHub Inc.) - initial API and implementation
 *******************************************************************************/
package org.eclipse.egit.ui.internal.history.command;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.egit.ui.Activator;
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.ui.PartInitException;

/**
 * Opens a {@link RevCommit} in the commit editor
 */
public class OpenInCommitViewerHandler extends AbstractHistoryCommandHandler {

	public Object execute(ExecutionEvent event) throws ExecutionException {
		Repository repository = getRepository(event);
		if (repository != null)
			for (Object selected : getSelection(getPage()).toList())
				try {
					CommitEditor.open(new RepositoryCommit(repository,
							(RevCommit) selected));
				} catch (PartInitException e) {
					Activator.showError("Error opening commit viewer", e); //$NON-NLS-1$
				}
		return null;
	}
}

@@ -584,16 +584,45 @@
 mmand;%0A%0A
+import java.io.IOException;%0A%0A
 import o
@@ -946,32 +946,73 @@
 walk.RevCommit;%0A
+import org.eclipse.jgit.revwalk.RevWalk;%0A
 import org.eclip
@@ -1321,16 +1321,64 @@
 != null)
+ %7B%0A%09%09%09RevWalk revWalk = new RevWalk(repository);
 %0A%09%09%09for 
@@ -1449,89 +1449,368 @@
 %09%09%09%09
-CommitEditor.open(new RepositoryCommit(repository,%0A%09%09%09%09%09%09%09(RevCommit) selected));
+RevCommit selectedCommit = (RevCommit) selected;%0A%0A%09%09%09%09%09// Re-parse commit to clear effects of TreeFilter%0A%09%09%09%09%09RevCommit reparsedCommit = revWalk.parseCommit(selectedCommit.getId());%0A%0A%09%09%09%09%09CommitEditor.open(new RepositoryCommit(repository, reparsedCommit));%0A%09%09%09%09%7D catch (IOException e) %7B%0A%09%09%09%09%09Activator.showError(%22Error opening commit viewer%22, e); //$NON-NLS-1$
 %0A%09%09%09
@@ -1922,16 +1922,20 @@
 $%0A%09%09%09%09%7D%0A
+%09%09%7D%0A
 %09%09return

Fix "Open in Commit Viewer" from resource-filtered History view