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

Store raw path bytes in Diff instances#474

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
Byron merged 1 commit intomasterfromkeep-raw-bytes-on-diffs
Jun 20, 2016

Conversation

nvie
Copy link
Contributor

Previously, the following fields on Diff instances were assumed to be passed in as unicode strings:

  • a_path
  • b_path
  • rename_from
  • rename_to

However, since Git natively records paths as bytes, these may potentially not have a valid unicode representation.

This patch changes the Diff instance to instead take the following equivalent fields that should be raw bytes instead:

  • a_rawpath
  • b_rawpath
  • raw_rename_from
  • raw_rename_to

NOTE ON BACKWARD COMPATIBILITY:
The originala_path,b_path, etc. fields are still available as properties (rather than slots). These properties now dynamically decode the raw bytes into a unicode string (performing the potentially
destructive operation of replacing invalid unicode chars by "�"'s).

This means that all code using Diffs should remain backward compatible. The only exception is when people would manually construct Diff instances by calling the constructor directly, in which case they should now pass in bytes rather than unicode strings.

See also the discussion on#467

Previously, the following fields on Diff instances were assumed to bepassed in as unicode strings:  - `a_path`  - `b_path`  - `rename_from`  - `rename_to`However, since Git natively records paths as bytes, these maypotentially not have a valid unicode representation.This patch changes the Diff instance to instead take the followingequivalent fields that should be raw bytes instead:  - `a_rawpath`  - `b_rawpath`  - `raw_rename_from`  - `raw_rename_to`NOTE ON BACKWARD COMPATIBILITY:The original `a_path`, `b_path`, etc. fields are still available asproperties (rather than slots).  These properties now dynamically decodethe raw bytes into a unicode string (performing the potentiallydestructive operation of replacing invalid unicode chars by "�"'s).This means that all code using Diffs should remain backward compatible.The only exception is when people would manually construct Diffinstances by calling the constructor directly, in which case they shouldnow pass in bytes rather than unicode strings.See also the discussion on#467
@nvie
Copy link
ContributorAuthor

@Byron What do you think of this?

@ByronByron added this to thev2.0.6 - Bugfixes milestoneJun 20, 2016
@Byron
Copy link
Member

I love it!

Even though it would have the potential to break people who did manually createDiff instances, I believe in this case, the benefits of the many should outweigh the ones of the few.

Thanks for your contribution, again :) !

@ByronByron merged commite9405ac intomasterJun 20, 2016
@nvie
Copy link
ContributorAuthor

Cheers, I've just released 2.0.6 to PyPI — thanks!

@nvienvie deleted the keep-raw-bytes-on-diffs branchJune 20, 2016 07:12
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees

@ByronByron

Development

Successfully merging this pull request may close these issues.

2 participants
@nvie@Byron

[8]ページ先頭

©2009-2025 Movatter.jp