Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
Pull request overview
Adds more robust overlay behavior in but-graph to support rebase-engine scenarios where references can be duplicated in overlays and where references can be explicitly “dropped” from traversal results.
Changes:
- Add
dropped_referencessupport toOverlayand enforce it in reference lookup + ref collection. - Define deterministic precedence for duplicate overlay references (first occurrence wins) and deduplicate refs across overlay/git/non-overriding sources.
- Add integration tests covering dropping refs (including HEAD ref) and duplicate override precedence.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| crates/but-graph/src/init/overlay.rs | Implements dropped-reference filtering, duplicate-reference precedence, and adjusts ref collection logic accordingly. |
| crates/but-graph/src/init/mod.rs | Extends Overlay struct with a dropped_references field and related docs. |
| crates/but-graph/tests/graph/init/overlay.rs | New tests validating dropped refs + duplicate override precedence behavior via snapshots. |
| crates/but-graph/tests/graph/init/mod.rs | Registers the new overlay test module. |
e9d716b to
25bad62
Compare
25bad62 to
311c8c8
Compare
| editor: Editor<'ws, 'meta, M>, | ||
| subject_commit: impl ToCommitSelector, | ||
| anchor: impl ToSelector, | ||
| side: InsertSide, | ||
| ) -> anyhow::Result<SuccessfulRebase<'ws, 'meta, M>> { | ||
| let sucessful_rebase = editor.rebase()?; | ||
| let workspace = sucessful_rebase.overlayed_graph()?.into_workspace()?; | ||
| let mut editor = sucessful_rebase.into_editor(); |
There was a problem hiding this comment.
move_commit calls editor.rebase() twice (once up-front to build a Workspace from overlayed_graph(), and again at the end). Editor::rebase() performs a full step traversal + cherry-pick loop (even for identity outcomes), so this duplicates potentially expensive work. Consider avoiding the initial rebase by using the already-available workspace/projection (e.g., pass &Workspace into this function, or add an accessor on Editor/SuccessfulRebase that doesn’t require running the rebase engine).
| editor: Editor<'ws, 'meta, M>, | |
| subject_commit: impl ToCommitSelector, | |
| anchor: impl ToSelector, | |
| side: InsertSide, | |
| ) -> anyhow::Result<SuccessfulRebase<'ws, 'meta, M>> { | |
| let sucessful_rebase = editor.rebase()?; | |
| let workspace = sucessful_rebase.overlayed_graph()?.into_workspace()?; | |
| let mut editor = sucessful_rebase.into_editor(); | |
| mut editor: Editor<'ws, 'meta, M>, | |
| subject_commit: impl ToCommitSelector, | |
| anchor: impl ToSelector, | |
| side: InsertSide, | |
| ) -> anyhow::Result<SuccessfulRebase<'ws, 'meta, M>> { | |
| let workspace = editor.overlayed_graph()?.into_workspace()?; |
There was a problem hiding this comment.
In practice, it's always going to be an identity operation, and the graph overlay should be a no-op. As such, the performance impact should be minimal. This is however gaining us the assurance that we're operating on the right graph data no matter what was called before the operation, which is quite valuable.
| let sucessful_rebase = editor.rebase()?; | ||
| let workspace = sucessful_rebase.overlayed_graph()?.into_workspace()?; | ||
| let mut editor = sucessful_rebase.into_editor(); |
There was a problem hiding this comment.
tear_off_branch calls editor.rebase() up-front solely to compute overlayed_graph()?.into_workspace(), and later calls editor.rebase() again to produce the returned SuccessfulRebase. Since Editor::rebase() runs the full rebase/cherry-pick loop, this doubles the amount of work for the operation. Consider restructuring so workspace context can be derived without running rebase() twice (e.g., pass &Workspace in, or expose a cheap accessor for the underlying workspace/projection).
311c8c8 to
acc8323
Compare
Byron
left a comment
There was a problem hiding this comment.
I think being able to turn an edit back into a graph is fantastic, and even more so because it's all in memory.
It's a bit sad that we have to hack around the lack of in-memory reference edits in gix::Repository, but so be it.
It's also great to have a couple of tests for the overlay, which I think could stay even once gix::Repository can do in-memory reference edits for good measure.
(This was a very quick armchair review for me and I only looked at but-graph, knowing that Overlay is just a means to an end)
This lets us emulate a reference that has been deleted as part of a graph overlay. uit tool changes
acc8323 to
60afb5d
Compare
60afb5d to
5917ab9
Compare
This function gives us access to what the but-graph would look like after materialization.
5917ab9 to
fd21e83
Compare
| if let Some(to_reference) = parents.first() | ||
| && let Step::Pick(Pick { id, .. }) = self.graph[*to_reference] | ||
| { | ||
| Some((id, Some(refname.clone()))) |
There was a problem hiding this comment.
In SuccessfulRebase::overlayed_graph, the Step::Reference arm binds id from Step::Pick(Pick { id, .. }) by reference (due to match ergonomics on &Step), but then returns it without dereferencing. This should be gix::ObjectId, not &gix::ObjectId, and will fail to compile. Dereference/copy the id (as done in the Step::Pick arm) before returning it.
| Some((id, Some(refname.clone()))) | |
| Some((*id, Some(refname.clone()))) |
As I’ve worked on using the graph overlay for the rebase engine, I’ve ended up encountering some situations that haven’t been covered before.
Namly:
For the former, there are a couple approaches we can take.
Of these, having some form of precidence seemed like the least invasive approach, so that is what I went with. Now, we take dropped references, then overrides from idx 0 to n, git references, and non-overrides from idx 0 to n.