zed-industries/zed · error

Stash has changed, not applying

Error message

Stash has changed, not applying

What it means

Guard in apply_stash: before applying, the stored stash sha is compared against the repository's current stash entry (stash_matches_index); when they diverge the stash list changed since the view was rendered, so applying could hit the wrong entry and is refused.

Solutions

  1. Abort the apply and inform the user the stash list changed
  2. Refresh the commit view / stash list so the UI shows current entries
  3. Ask the user to re-invoke the action against the refreshed list
  4. Never apply by index without verifying the sha first
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/git_ui/src/commit_view.rs:780 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/9f6b3e2c64fa64f9. Report an issue: GitHub.

Appendix: source

Thrown at crates/git_ui/src/commit_view.rs:780

                                        .track_scroll(&self.message_scroll_handle)
                                })
                                .child(MarkdownElement::new(self.message.clone(), markdown_style)),
                        )
                        .vertical_scrollbar_for(&self.message_scroll_handle, window, cx),
                ),
        )
    }

    fn apply_stash(workspace: &mut Workspace, window: &mut Window, cx: &mut App) {
        Self::stash_action(
            workspace,
            "Apply",
            window,
            cx,
            async move |repository, sha, stash, commit_view, workspace, cx| {
                let result = repository.update(cx, |repo, cx| {
                    if !stash_matches_index(&sha, stash, repo) {
                        return Err(anyhow::anyhow!("Stash has changed, not applying"));
                    }
                    Ok(repo.stash_apply(Some(stash), cx))
                });

                match result {
                    Ok(task) => task.await?,
                    Err(err) => {
                        Self::close_commit_view(commit_view, workspace, cx).await?;
                        return Err(err);
                    }
                };
                Self::close_commit_view(commit_view, workspace, cx).await?;
                anyhow::Ok(())
            },
        );
    }

    fn pop_stash(workspace: &mut Workspace, window: &mut Window, cx: &mut App) {

View on GitHub (pinned to f4178619ac)