From 2d5c4cede1c20fbe209d414ce52aa34da7bb8013 Mon Sep 17 00:00:00 2001
From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
Date: Tue, 5 May 2026 17:07:52 -0400
Subject: [PATCH] git_graph: Keep shared parents on the leftmost incoming lane
(#55818)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes git graph lane selection when multiple active lanes point to the
same parent commit, matching Git’s `--graph` behavior by keeping the
commit on the leftmost incoming lane instead of the first discovered
lane.
This should make it much easier to track long lived branches
### Before
### After
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 is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
Release Notes:
- N/A
---------
Co-authored-by: Remco Smits
---
crates/git_graph/src/git_graph.rs | 72 ++++++++++++++++++++++++++++++-
1 file changed, 71 insertions(+), 1 deletion(-)
diff --git a/crates/git_graph/src/git_graph.rs b/crates/git_graph/src/git_graph.rs
index 73ad9293e1..ac9a01deb9 100644
--- a/crates/git_graph/src/git_graph.rs
+++ b/crates/git_graph/src/git_graph.rs
@@ -640,7 +640,7 @@ impl GraphData {
let commit_lane = self
.parent_to_lanes
.get(&commit.sha)
- .and_then(|lanes| lanes.first().copied());
+ .and_then(|lanes| lanes.iter().min().copied());
let commit_lane = commit_lane.unwrap_or_else(|| self.first_empty_lane_idx());
@@ -4049,6 +4049,74 @@ mod tests {
Ok(())
}
+ fn verify_keep_shared_parents_on_leftmost_lane(graph: &GraphData) -> Result<()> {
+ let mut active_lane_parents: Vec