Skip to content

Updated branch creation implementation.#12664

Merged
Caleb-T-Owens merged 1 commit intomasterfrom
branch-creation-2.0
Mar 4, 2026
Merged

Updated branch creation implementation.#12664
Caleb-T-Owens merged 1 commit intomasterfrom
branch-creation-2.0

Conversation

@Caleb-T-Owens
Copy link
Contributor

This new algorithm is more closely tied to the but graph.

The old algirithm treated references like things that belonged to commits which made it hard to figure out which of the many permutations of inter-reference relations was the one we should express.

This new algirithm has an intermediate step which is more similar to the but-graph represenation which allows us to take the but-graph relations when it’s accurate, before falling back to true commit parantage.

Copilot AI review requested due to automatic review settings March 3, 2026 13:22
@vercel
Copy link

vercel bot commented Mar 3, 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 Mar 3, 2026 4:22pm

Request Review

@github-actions github-actions bot added the rust Pull requests that update Rust code label Mar 3, 2026
Copy link
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

This PR updates but-rebase’s branch creation/editor construction to build a step graph that more directly mirrors but-graph segment relationships, with fallback behavior when the segment graph is inconsistent with the commit graph.

Changes:

  • Reworks GraphExt::to_editor() to build per-segment step chains (segment ref → commit refs → pick) and then connect segments.
  • Adds preserved-parent handling for commits whose parents are not present in the traversed graph.
  • Simplifies segment-parent discovery to return only parent commit IDs (dropping the prior “via reference” annotation).

@Caleb-T-Owens Caleb-T-Owens marked this pull request as draft March 3, 2026 13:34
@Caleb-T-Owens Caleb-T-Owens force-pushed the branch-creation-2.0 branch 2 times, most recently from 4fc6d0d to 88e7454 Compare March 3, 2026 16:08
This new algorithm is more closely tied to the but graph.

The old algirithm treated references like things that belonged to commits which made it hard to figure out which of the many permutations of inter-reference relations was the one we should express.

This new algirithm has an intermediate step which is more similar to the but-graph represenation which allows us to take the but-graph relations _when_ it’s accurate, before falling back to true commit parantage.
@Caleb-T-Owens Caleb-T-Owens marked this pull request as ready for review March 3, 2026 16:23
Copilot AI review requested due to automatic review settings March 3, 2026 16:23
Copy link
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 3 out of 3 changed files in this pull request and generated 3 comments.

Comment on lines 34 to +36
let mut commits: Vec<Commit> = vec![];
// References are ordered from child-most to parent-most
let mut references: BTreeMap<gix::ObjectId, Vec<gix::refs::FullName>> = BTreeMap::new();

let mut head_refname = None;
let workspace_commit_id = self.managed_entrypoint_commit(repo)?.map(|c| c.id);
let mut commit_to_idx = HashMap::<gix::ObjectId, SegmentIndex>::new();
let mut commit_to_pick_ix = HashMap::<gix::ObjectId, StepGraphIndex>::new();
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

commit_to_idx is populated but never read. This will trigger an unused-variable warning (and can become a CI failure under clippy/deny-warnings). Remove it, or use it if it's intended for later logic.

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +30
// reachable from the entrypoint TODO(CTO): Look into stopping at the
// common base
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The TODO comment got collapsed into a single sentence (...entrypoint TODO(CTO): ...), which reads like two TODOs missing a newline. Split these into separate comment lines so it’s clear they are distinct items.

Suggested change
// reachable from the entrypoint TODO(CTO): Look into stopping at the
// common base
// reachable from the entrypoint
// TODO(CTO): Look into stopping at the common base

Copilot uses AI. Check for mistakes.
.collect::<Vec<_>>();

for reference in refs {
references.push(reference.to_owned());
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

In this loop, reference is already an owned FullName (it came from a .clone() earlier), but it’s cloned again via to_owned() when pushing into references. This adds extra allocations/clones for every ref; consider pushing/moving reference into references and cloning only for the Step::Reference node (or vice versa).

Suggested change
references.push(reference.to_owned());
references.push(reference);

Copilot uses AI. Check for mistakes.
@Caleb-T-Owens Caleb-T-Owens merged commit 4e9fa42 into master Mar 4, 2026
37 checks passed
@Caleb-T-Owens Caleb-T-Owens deleted the branch-creation-2.0 branch March 4, 2026 13:59
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.

2 participants