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

Bug fix for one-liner diffs #2

Merged

Conversation

thoward
Copy link
Contributor

@thoward thoward commented Oct 1, 2015

This change fixes unified diff parsing to work correctly for one-liner files. Previously, the parser was giving no output in those situations.

Steps to reproduce:

$ mkdir test_repo
$ cd test_repo
$ git init
$ echo "Adding a one-line file." > oneline.txt
$ git commit -am "Add a file"
$ echo "Changed a one-line file." > oneline.txt
$ git commit -am "Changed a file"
$ git rm oneline.txt
$ git commit -m "Delete a file"
$ git log -p

Grab any of the diffs in that git log. None of them would parse correctly. This is because the comparison in parse_unified_diff of the line offsets r and i were bypassing at 0 when no old_len/new_len value was available.

I've included unit tests and casefile fixtures for this change. This does not break any other unit tests, although there are an unrelated set of 3 tests which are currently broken (as described in issue #1).

Separately, I did look into to those failing tests and I can see that these are intentional test failures, because they are testing not-yet-implemented features. Yay TDD!

@cscorley
Copy link
Owner

cscorley commented Oct 1, 2015

Great catch and PR! Thanks so much.

cscorley added a commit that referenced this pull request Oct 1, 2015
@cscorley cscorley merged commit 4e577b2 into cscorley:master Oct 1, 2015
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