Skip to content

update-graph-overlay#13080

Merged
Caleb-T-Owens merged 4 commits intomasterfrom
update-graph-overlay
Apr 7, 2026
Merged

update-graph-overlay#13080
Caleb-T-Owens merged 4 commits intomasterfrom
update-graph-overlay

Conversation

@Caleb-T-Owens
Copy link
Copy Markdown
Contributor

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:

  • What happens if a reference is specified multiple times in the overlays list.
  • How can I express dropping a commit.

For the former, there are a couple approaches we can take.

  • Define some precidence for duplicate references
  • bail in some way if we see duplicate references defined
  • Define some type that can’t have multiple references added

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.

Copilot AI review requested due to automatic review settings March 27, 2026 19:47
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gitbutler-web Ignored Ignored Preview Apr 7, 2026 10:31am

Request Review

@github-actions github-actions bot added the rust Pull requests that update Rust code label Mar 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_references support to Overlay and 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.

@Caleb-T-Owens Caleb-T-Owens enabled auto-merge March 28, 2026 05:39
Copilot AI review requested due to automatic review settings March 31, 2026 00:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Comment on lines +28 to +35
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();
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
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()?;

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment on lines +55 to +57
let sucessful_rebase = editor.rebase()?;
let workspace = sucessful_rebase.overlayed_graph()?.into_workspace()?;
let mut editor = sucessful_rebase.into_editor();
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@Byron Byron left a comment

Choose a reason for hiding this comment

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

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
Copilot AI review requested due to automatic review settings April 7, 2026 09:09
@Caleb-T-Owens Caleb-T-Owens force-pushed the update-graph-overlay branch from acc8323 to 60afb5d Compare April 7, 2026 09:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

@Caleb-T-Owens Caleb-T-Owens force-pushed the update-graph-overlay branch from 60afb5d to 5917ab9 Compare April 7, 2026 10:14
This function gives us access to what the but-graph would look like after materialization.
Copilot AI review requested due to automatic review settings April 7, 2026 10:31
@Caleb-T-Owens Caleb-T-Owens force-pushed the update-graph-overlay branch from 5917ab9 to fd21e83 Compare April 7, 2026 10:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

if let Some(to_reference) = parents.first()
&& let Step::Pick(Pick { id, .. }) = self.graph[*to_reference]
{
Some((id, Some(refname.clone())))
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
Some((id, Some(refname.clone())))
Some((*id, Some(refname.clone())))

Copilot uses AI. Check for mistakes.
@Caleb-T-Owens Caleb-T-Owens merged commit f3f5e0b into master Apr 7, 2026
41 checks passed
@Caleb-T-Owens Caleb-T-Owens deleted the update-graph-overlay branch April 7, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants