From e5535ffc3c304882ecf0ed69c5ac3ff24696b333 Mon Sep 17 00:00:00 2001 From: Stanislau Palyn Date: Fri, 5 Sep 2025 20:22:38 +0200 Subject: [PATCH] [git] IJPL-204934 Ensure proper cleanup of structured activities in GitCheckoutOperation GitOrigin-RevId: 3929564f04e7009ce1595a6f70070f81217980bf --- .../git4idea/branch/GitCheckoutOperation.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java index 62817e1af636..7f3128996ee4 100644 --- a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java @@ -134,13 +134,23 @@ class GitCheckoutOperation extends GitBranchOperation { new GitUntrackedFilesOverwrittenByOperationDetector(root); StructuredIdeActivity checkoutOperation = CHECKOUT_OPERATION.startedWithParent(myProject, activity); - GitCommandResult result = myGit.checkout(repository, myStartPointReference, myNewBranch, false, myDetach, myReset, - localChangesDetector, unmergedFiles, unknownPathspec, untrackedOverwrittenByCheckout); - checkoutOperation.finished(); + GitCommandResult result; + try { + result = myGit.checkout(repository, myStartPointReference, myNewBranch, false, myDetach, myReset, + localChangesDetector, unmergedFiles, unknownPathspec, untrackedOverwrittenByCheckout); + } + finally { + checkoutOperation.finished(); + } + if (result.success()) { StructuredIdeActivity vfsRefresh = VFS_REFRESH.startedWithParent(myProject, activity); - updateAndRefreshChangedVfs(repository, startHash); - vfsRefresh.finished(); + try { + updateAndRefreshChangedVfs(repository, startHash); + } + finally { + vfsRefresh.finished(); + } markSuccessful(repository); } else if (unmergedFiles.isDetected()) {