Closes #26866 ### Summary Adds a git graph to Zed, accessible via the `git_graph::Open` action if a project has an active repository. There's still more to do, but this is a solid foundation to expand upon. The code structure is in line with Zed's codebase and shouldn't require architectural changes to add missing features. The git graph can be opened via the command palette (`git graph: open`) or by binding a key to `git_graph::Open`. It's available when the project has an active git repository. ### Architecture Similar to the Debugger, the git graph is split between a data layer and a view/UI layer. When the view layer is rendering, it queries the data layer for its active state. This setup allows the data layer to lazily request graph data (only when needed for rendering), abstracts collab from the view layer, allows most of the data loading to happen on a background thread, and makes caching easy to implement. #### Graph Loading The graph data is loaded in two phases: 1. `Repository::graph_data()` streams commit structure (SHA, parents, refs) in chunks of 1000 via `git log` 2. `CommitDataReader` lazily fetches full commit details (author, timestamp, subject) on-demand using a persistent `git cat-file --batch` process This two-phase approach makes the initial loading of the graph as fast as possible, because `git log` takes significantly longer when all the needed graph data is queried through it. Zed then lazily loads commits in the user's viewport through `cat-file --batch`. This makes scrolling to any place in the graph extremely snappy and benefits the collaborative architecture by only fetching data needed to render the graph. It also allows Zed to share commit data between different graph visualizations (e.g., date order vs. topological order). #### Performance Tested on both the Zed and LLVM repositories with good performance in both cases. The two-phase loading approach and lazy fetching keep the UI responsive even with large commit histories. #### Testing I added property testing that builds randomized commit graphs and verifies that the graph is constructed correctly. This also works as an integration test and will be expanded in the future to test collab graph visualization, graph filtering, commit actions, etc. ### New Crate - `git_graph` (GPL-licensed) — contains UI and graph computation logic ### Not Yet Implemented - Remote repository support (collab) - Filtering by branch - Commit actions (checkout, cherry-pick, etc.) - Search - Open commit view for selected commit - Resizable columns - Column filtering #### Reference <img width="1624" height="976" alt="Screenshot 2025-01-22 at 8 15 39 PM" src="https://github.com/user-attachments/assets/0f10924a-3964-462f-b320-42d84d02f7bf" /> Special thanks to [Alberto Slavica](https://github.com/pyundev) for submitting #44405, which was a good base to work off of. Release Notes: - git: Add initial version of git graph --------- Co-authored-by: pyundev <pyundev@users.noreply.github.com> Co-authored-by: Cole Miller <cole@zed.dev> Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).
Other platforms are not yet available:
- Web (tracking issue)
Developing Zed
Contributing
See CONTRIBUTING.md for ways you can contribute to Zed.
Also... we're hiring! Check out our jobs page for open roles.
Licensing
License information for third party dependencies must be correctly provided for CI to pass.
We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:
- Is it showing a
no license specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Sponsorship
Zed is developed by Zed Industries, Inc., a for-profit company.
If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.