Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where colons in paths raise a ValueError on diff() calls. #1491

Merged
merged 1 commit into from Sep 14, 2022
Merged

Conversation

langfield
Copy link
Contributor

This commit introduces a potential fix for #1490 and #1483, in which an invalid literal for int() with base 10: 'n' exception was raised within a diff operation. Within _handle_diff_line(), we split the output of git diff-tree on colons (: characters), under the assumption that there are no colons within the paths of the files being diffed. On POSIX systems this is not a valid assumption. The fix is to split on \x00:, since a null character always precedes the colons we actually need to split on.

A test already existed for this case (test_diff_file_with_colon()), but it was marked as skipped.

  • Split on \x00: instead of : in _handle_diff_line().
  • Unskip test_diff_file_with_colon().

@langfield langfield changed the title Fix bug where colons in paths raise a ValueError on diff() calls. WIP: Fix bug where colons in paths raise a ValueError on diff() calls. Sep 12, 2022
@Byron Byron marked this pull request as draft September 12, 2022 23:08
This commit introduces a potential fix for #1490 and #1483, in which an
`invalid literal for int() with base 10: 'n'` exception was raised
within a diff operation. Within `_handle_diff_line()`, we split the
output of `git diff-tree` on colons (`:` characters), under the
assumption that there are no colons within the paths of the files being
diffed. On POSIX systems this is not a valid assumption. The fix is to
split on `\x00:`, since a null character always precedes the colons we
actually need to split on.

A test already existed for this case (`test_diff_file_with_colon()`),
but it was marked as skipped.

* Split on `\x00:` instead of `:` in `_handle_diff_line()`.
* Unskip `test_diff_file_with_colon()`.
@langfield langfield changed the title WIP: Fix bug where colons in paths raise a ValueError on diff() calls. Fix bug where colons in paths raise a ValueError on diff() calls. Sep 13, 2022
@langfield langfield marked this pull request as ready for review September 13, 2022 02:21
@Byron Byron added this to the v3.1.28 - Bugfixes milestone Sep 14, 2022
@Byron
Copy link
Member

Byron commented Sep 14, 2022

Thanks a lot! Amazing to see how close this issue was to a resolution all the time, and I am glad it's finally here now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants