Fix a panic when git askpass triggers during commit (#50057) (cherry-pick to preview) (#50059)

zed-zippy[bot] and Conrad Irwin created

Cherry-pick of #50057 to preview

----
Fixes ZED-597

Release Notes:

- Fixed a panic when the askpass dialogue opened while committing.

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>

Change summary

crates/git_ui/src/git_panel.rs | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

Detailed changes

crates/git_ui/src/git_panel.rs 🔗

@@ -3171,18 +3171,16 @@ impl GitPanel {
         window: &mut Window,
         cx: &mut Context<Self>,
     ) -> AskPassDelegate {
-        let this = cx.weak_entity();
+        let workspace = self.workspace.clone();
         let operation = operation.into();
         let window = window.window_handle();
         AskPassDelegate::new(&mut cx.to_async(), move |prompt, tx, cx| {
             window
                 .update(cx, |_, window, cx| {
-                    this.update(cx, |this, cx| {
-                        this.workspace.update(cx, |workspace, cx| {
-                            workspace.toggle_modal(window, cx, |window, cx| {
-                                AskPassModal::new(operation.clone(), prompt.into(), tx, window, cx)
-                            });
-                        })
+                    workspace.update(cx, |workspace, cx| {
+                        workspace.toggle_modal(window, cx, |window, cx| {
+                            AskPassModal::new(operation.clone(), prompt.into(), tx, window, cx)
+                        });
                     })
                 })
                 .ok();