From 4b254c2da56e2b3a2faf41d3136c188350e00d44 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Fri, 13 Dec 2024 17:21:25 +0100 Subject: [PATCH] Git - auto stash should restore the stash when the operation fails (#232929) (#236059) --- extensions/git/src/repository.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index e3b924d5868..73a54cef4af 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -2465,10 +2465,12 @@ export class Repository implements Disposable { } await this.repository.createStash(undefined, true); - const result = await runOperation(); - await this.repository.popStash(); - - return result; + try { + const result = await runOperation(); + return result; + } finally { + await this.repository.popStash(); + } } private onFileChange(_uri: Uri): void {