Conversation
…on of shifted lines When git diff absorbs shifted pre-existing lines into a replacement hunk (e.g. a comment deletion adjacent to a large addition), those lines appear as `+` in the diff. Without `-C`, git blame attributes them to the current commit rather than the originating one, causing false Human attribution for AI-written lines. Setting `detect_copies: 1` enables `-C` so git blame detects within-commit line movement and correctly traces the lines back to their originating commit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… test blame_hunks_for_ranges read GitAiBlameOptions.detect_copies but never translated it into -C flags on the git-blame command line, making the detect_copies: 1 set in apply_blame_for_side entirely inert. Add the translation (and the parallel -M path for detect_moves) so that git blame actually receives -C/-M when requested. Add test_diff_blame_uses_detect_copies_for_moved_ai_lines which: - Creates commit A where an AI writes func_one and func_two. - Creates commit B where the AI adds new_func and func_one is moved to the end (Myers diff represents this as explicit + lines, not context). - Without -C git blame attributes the moved func_one lines to B (which has no attestation for them) → wrongly shown as Human. - With -C git blame traces them back to A's attestation → correctly AI. The test is verified to fail on the un-fixed code and pass with the fix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
blame_hunks_for_rangesinsrc/commands/blame.rsnow translatesdetect_copies/detect_movesonGitAiBlameOptionsinto-C/-Mflags on the git-blame command line.apply_blame_for_sideinsrc/commands/diff.rsalready setdetect_copies: 1, but the field was never wired through to the actual git invocation — the fix was inert (caught by Devin review).test_diff_blame_uses_detect_copies_for_moved_ai_linesthat fails on the broken code and passes with the fix.Root cause
When a commit moves a substantial block of lines to a different position within a file (e.g. reordering functions), Myers diff represents the moved block as explicit
+lines. Those lines end up inapply_blame_for_side'sadded_linesset. Without-C(which implies-M),git blameattributes them to the current commit rather than the original one — so they fall through as Human when the current commit has no attestation covering them. With-C, git blame detects the within-file move and correctly traces the lines back to the originating commit.Observed on commit
7b99854f(100% AI-authored):git ai diffshowed 4 lines attributed to Human becausegit blamewithout-Cplaced them in the current commit rather than parent6ff95531where the covering attestation lived.Regression test
test_diff_blame_uses_detect_copies_for_moved_ai_lines:func_one(6 lines) +func_two(6 lines), both fully AI-attested.new_func(attested in B) andfunc_oneshifts to the end. Myers diff representsfunc_oneas+lines at its new position.-C: git blame says the movedfunc_onelines were introduced in B → no attestation in B → Human ❌-C: git blame traces them back to A → A's attestation covers them → AI ✓Test plan
cargo test --test integration -- diff— all 201 tests pass (1 new test added)test_search_by_commit_range_in_worktree— a daemon sync timeout unrelated to this change; the same test passes on ubuntu wrapper and ubuntu daemon modes.