From f90ae3a85d421e5bdc46ea42520d261df12b2a6f Mon Sep 17 00:00:00 2001
From: Eric Amodio <eamodio@gmail.com>
Date: Fri, 20 Oct 2023 19:45:39 -0400
Subject: [PATCH] Fixes opening stash details from view

---
 src/commands/showCommitsInView.ts | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/commands/showCommitsInView.ts b/src/commands/showCommitsInView.ts
index 562eb62..9ef68cd 100644
--- a/src/commands/showCommitsInView.ts
+++ b/src/commands/showCommitsInView.ts
@@ -4,7 +4,8 @@ import type { Container } from '../container';
 import { executeGitCommand } from '../git/actions';
 import { showDetailsView } from '../git/actions/commit';
 import { GitUri } from '../git/gitUri';
-import { createReference } from '../git/models/reference';
+import type { GitRevisionReference } from '../git/models/reference';
+import { createReference, getReferenceFromRevision } from '../git/models/reference';
 import { createSearchQueryForCommits } from '../git/search';
 import { showFileNotUnderSourceControlWarningMessage, showGenericErrorMessage } from '../messages';
 import { command } from '../system/command';
@@ -14,6 +15,7 @@ import type { CommandContext } from './base';
 import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasCommit } from './base';
 
 export interface ShowCommitsInViewCommandArgs {
+	ref?: GitRevisionReference;
 	refs?: string[];
 	repoPath?: string;
 }
@@ -35,8 +37,7 @@ export class ShowCommitsInViewCommand extends ActiveEditorCommand {
 		if (context.type === 'viewItem') {
 			args = { ...args };
 			if (isCommandContextViewNodeHasCommit(context)) {
-				args.refs = [context.node.commit.sha];
-				args.repoPath = context.node.commit.repoPath;
+				args.ref = getReferenceFromRevision(context.node.commit);
 			}
 		}
 
@@ -46,6 +47,8 @@ export class ShowCommitsInViewCommand extends ActiveEditorCommand {
 	async execute(editor?: TextEditor, uri?: Uri, args?: ShowCommitsInViewCommandArgs) {
 		args = { ...args };
 
+		if (args.ref != null) return showDetailsView(args.ref);
+
 		if (args.refs === undefined) {
 			uri = getCommandUri(uri, editor);
 			if (uri == null) return undefined;