Skip to content

fix: preserve Graphite modify-into attribution - #2015

Open
svarlamov wants to merge 1 commit into
fix/graphite-modify-into-regression-jul-28from
fix/graphite-modify-into-attribution-jul-28
Open

fix: preserve Graphite modify-into attribution#2015
svarlamov wants to merge 1 commit into
fix/graphite-modify-into-regression-jul-28from
fix/graphite-modify-into-attribution-jul-28

Conversation

@svarlamov

@svarlamov svarlamov commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

Preserves AI attribution when Graphite moves uncommitted child-branch changes into a downstack branch with gt modify --into.

Root cause

Graphite first creates graphite (temporary): staged changes, then synthesizes the rewritten downstack commit with commit-tree and merge-tree. Git AI attached the new attribution to the temporary commit, but normal range-diff mapping only related the old downstack commit to its replacement. Because the temporary commit was outside that rewritten range, its note was never merged into the replacement and the newly added lines became unknown.

Fix

  • Remember one exact Graphite temporary commit candidate per worktree after its normal post-commit note is written.
  • On the following branch update-ref, require the old target to be an ancestor of the parent of the temporary commit.
  • Fail closed unless the raw binary tree delta from temporary parent to temporary commit exactly equals the old-target to new-target delta.
  • When those immutable deltas match, include the temporary commit as an additional note source for the existing batched rewrite path.
  • Clear the bounded candidate after the branch update.

The validation is constant work and only runs for the exact Graphite temporary-commit sequence: one ancestry check and two diff-tree calls, with no history scan or per-commit loop.

Tests

  • Real unauthenticated gt modify --all --into end-to-end regression.
  • Exact Graphite plumbing reproduction from the captured logs.
  • Negative mismatch case proving an unrelated rewrite cannot inherit attribution from the temporary commit.
  • task fmt
  • task lint
  • task test

Copy link
Copy Markdown
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant