Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix diff patch parsing#412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nvie merged 5 commits intogitpython-developers:masterfromnvie:fix-diff-patch-parsing
Apr 19, 2016
Merged

Fix diff patch parsing#412

nvie merged 5 commits intogitpython-developers:masterfromnvie:fix-diff-patch-parsing
Apr 19, 2016

Conversation

nvie
Copy link
Contributor

NOTE: This PR builds on#408, so please merge that one first.


The a_path and b_path cannot reliably be read from the first diff line as it's ambiguous. From the git-diff manpage:

"The a/ and b/ filenames are the same unless rename/copy is involved. Especially,even for a creation or a deletion, /dev/null is not used in place of the a/ or b/ filenames."

This patch changes the a_path and b_path detection to read it from the more reliable locations further down the diff headers. Two use cases are fixed by this:

  • As the man page snippet above states, for new/deleted files the a or b path will now be properly None.
  • File names with spaces in it are now properly parsed.

Working on this patch, I realized the --- and +++ lines really belong to the diff header, not the diff contents. This means that when parsing the patch format, the --- and +++ will now be swallowed, and not end up anymore as part of the diff contents. The diff contents now always start with an @@ line.

This may be a breaking change for some users that rely on this behaviour. However, those users could now access that information more reliably via the normal Diff properties a_path and b_path now.

@nvie
Copy link
ContributorAuthor

Going to rebase this against the latestmaster, to make this more readable.

The a_path and b_path cannot reliably be read from the first diff lineas it's ambiguous.  From the git-diff manpage:  > The a/ and b/ filenames are the same unless rename/copy is involved.  > Especially, **even for a creation or a deletion**, /dev/null is not  > used in place of the a/ or b/ filenames.This patch changes the a_path and b_path detection to read it from themore reliable locations further down the diff headers.  Two use casesare fixed by this:  - As the man page snippet above states, for new/deleted files the a    or b path will now be properly None.  - File names with spaces in it are now properly parsed.Working on this patch, I realized the --- and +++ lines really belong tothe diff header, not the diff contents.  This means that when parsingthe patch format, the --- and +++ will now be swallowed, and not end upanymore as part of the diff contents.  The diff contents now alwaysstart with an @@ line.This may be a breaking change for some users that rely on thisbehaviour.  However, those users could now access that information morereliably via the normal Diff properties a_path and b_path now.
This makes sure we're not matching a \n here by accident.  It's nowalmost the same as the original that used \S+, except that spaces arenot eaten at the end of the string (for files that end in a space).
When both old/new mode and rename from/to lines are found, they willappear in different order.
@nvienvie merged commit8bbf1a3 intogitpython-developers:masterApr 19, 2016
@nvienvie deleted the fix-diff-patch-parsing branchApril 19, 2016 19:47
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@nvie

[8]ページ先頭

©2009-2025 Movatter.jp