# git_panel: Show staged and unstaged diff stats \(\#60815\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/54fdf58d3a5ba58e3d71fdd862f47cf5ebc05698)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 54fdf58d3a5ba58e3d71fdd862f47cf5ebc05698

Requested commit: 54fdf58d3a5ba58e3d71fdd862f47cf5ebc05698

Commit: 54fdf58d3a5ba58e3d71fdd862f47cf5ebc05698

Tree: 10dc289a7236786af858d33c0401dbc25f735f1d

Author: Sathwik Chirivelli

Committer: GitHub

## Message

```
git_panel: Show staged and unstaged diff stats (#60815)

# Objective

- Show accurate diff stats for each staged and unstaged projection of a
partially staged file in the Git panel.
- This was originally considered for
https://github.com/zed-industries/zed/pull/59884, but was scoped out of
that already-large PR and is being submitted separately as discussed
there.

## Solution

- Collect HEAD-to-index and index-to-worktree diff stats alongside the
existing combined HEAD-to-worktree stats.
- Carry the staged and unstaged stats through repository status
snapshots and remote status serialization.
- Use the stat matching the projected Git panel section while preserving
the combined stat for the other grouping modes.
- Update the fake Git repository and add regression coverage with
deliberately different staged and unstaged counts.

## Testing

- `cargo check -p git_ui`
- `cargo check -p collab`
- `cargo test -p git_ui
test_group_by_staging_section_membership_and_order --lib`
- `cargo test -p project --lib --no-run`
- `cargo fmt --all -- --check`
- `git diff --check`

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed diff stats for partially staged files in the Git panel
```

## Parents

- [eb962794a33cbd414c6a343a8bb1136c94fe6901](https://git.cafe/gitcafe/zed/commit/eb962794a33cbd414c6a343a8bb1136c94fe6901?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/54fdf58d3a5ba58e3d71fdd862f47cf5ebc05698?format=markdown)
