Skip to content

Conversation

@AlvaroParker
Copy link
Contributor

@AlvaroParker AlvaroParker commented Sep 16, 2025

Continues the work from #35927 to add a git diff view for stash entries.

Screencast.From.2025-09-17.19-46-01.webm

Stash entries are represented as commits except they have up to 3 parents:

       .----W (this is the stash entry)
      /    /|
-----H----I |
           \|
            U

Where H is the HEAD commit, I is a commit that records the state of the index, and U is another commit that records untracked files (when using git stash -u).

Given this, I modified the existing commit view struct to allow loading stash and commits entries with git sha identifier so that we can get a similar git diff view for both of them.

The stash diff is generated by comparing the stash commit with its parent (<commit>^ or H in the diagram) which generates the same diff as doing git stash show -p <stash entry>. This can be counter-intuitive since a user may expect the comparison to be made between the stash commit and the current commit (HEAD), but given that the default behavior in git cli is to compare with the stash parent, I went for that approach.

Hoping to get some feedback from a Zed team member to see if they agree with this approach.

Release Notes:

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Sep 16, 2025
@AlvaroParker AlvaroParker force-pushed the implement-stash-view branch 3 times, most recently from 0b98347 to 5b99d02 Compare September 21, 2025 15:57
@AlvaroParker AlvaroParker force-pushed the implement-stash-view branch 2 times, most recently from 90ce54f to e614ce3 Compare September 25, 2025 22:03
@AlvaroParker AlvaroParker marked this pull request as ready for review September 26, 2025 12:26
@AlvaroParker AlvaroParker force-pushed the implement-stash-view branch 3 times, most recently from 8a41a85 to b9339ed Compare September 30, 2025 16:39
@AlvaroParker
Copy link
Contributor Author

Hey @cole-miller, sorry to ping you here! Just wanted to check if there's anything I can change or improve to help move this along, let me know. Thanks, and sorry again for the ping :)

(same goes for #38719)

Copy link
Member

@cole-miller cole-miller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AlvaroParker and sorry for not reviewing this sooner--the code and design here generally look great, well done! I really like how this reuses the existing commit view and even simplifies it a little bit in the process. I just have a couple of small design comments and then this should be good to merge.

@cole-miller
Copy link
Member

Thanks @AlvaroParker, nicely done!

@cole-miller cole-miller enabled auto-merge (squash) October 20, 2025 15:22
@cole-miller cole-miller merged commit db404fc into zed-industries:main Oct 20, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

2 participants