plumbing/format/diff: use git's funcname heuristic for hunk context#2238
Draft
SillyZir wants to merge 1 commit into
Draft
plumbing/format/diff: use git's funcname heuristic for hunk context#2238SillyZir wants to merge 1 commit into
SillyZir wants to merge 1 commit into
Conversation
The unified diff encoder used the line immediately preceding a change as
the hunk header context, producing "@@ ... @@ {" where git shows the
enclosing function line, e.g. "@@ ... @@ int main(int argc, char *argv[])".
Search backwards for a line matching git's default funcname heuristic
(first character a letter, '_' or '$') and carry the last match across
hunks, matching git's output.
Signed-off-by: SillyZir <269283839+SillyZir@users.noreply.github.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.
Fixes #2193.
go-git's unified diff used the line immediately before a change as the hunk header context (
@@ ... @@ {), whereas git shows the enclosing function or section line (@@ ... @@ int main(int argc, char *argv[])).This searches backward for a line matching git's default funcname heuristic (first character a letter,
_, or$) and carries the last match across hunks, matching git's output.Affected package tests pass locally.