Skip to content

fix(git): synthesize diff line sigils in patches - #343

Open
linbingquan wants to merge 2 commits into
mufeedvh:mainfrom
linbingquan:dev
Open

linbingquan wants to merge 2 commits into
mufeedvh:mainfrom
linbingquan:dev

Conversation

@linbingquan

Copy link
Copy Markdown

As the title says.

Generated with AI assistance.

`git2`'s `DiffLine::content()` omits the `+`/`-`/space origin
prefix, so generated patches were missing line markers. Add a
`write_diff_line` helper that prepends the appropriate sigil for
content lines while leaving file headers, hunk headers, binary
notices, and EOF markers untouched, and use it for staged,
unstaged, and branch-to-branch diffs.

Add unit tests covering content lines, headers, binary notices,
and `\ No newline at end of file` markers.
@linbingquan linbingquan changed the title fix(core): restore +/- prefixes in git diff output fix(git): synthesize diff line sigils in patches Oct 16, 2026

@ODAncona ODAncona left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The test should be in a separate file.

@linbingquan

Copy link
Copy Markdown
Author

Thanks for the suggestion. I moved the write_diff_line tests out of the inline mod tests block.

If the PR has any problem, please tell me.

This branch has not been deployed

No deployments
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.

2 participants