Skip to content

Fix support for empty diffs (new, deleted, renamed, binary files). #13

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

Merged
merged 1 commit into from
May 20, 2016

Conversation

dmitshur
Copy link
Contributor

@dmitshur dmitshur commented May 9, 2016

DO NOT MERGE, this is a WIP PR and there are known TODOs to resolve. Early review (comments, suggestions) is welcome. Edit: Ready for review and merge.

There are situations where a diff is empty. For example, if a blank file is added a removed. Or if a file is renamed without any changes. This change detects and handles those situations properly. Edit: Or if the file modified is binary.

Improve test coverage significantly.

TODO

  • Update .proto and regenerate .pb.go.

Fixes #10.

@dmitshur dmitshur force-pushed the fix-empty-diffs branch from 891144f to 9d302e3 Compare May 9, 2016 08:43
@dmitshur dmitshur force-pushed the fix-empty-diffs branch from 9d302e3 to d15cab2 Compare May 9, 2016 09:03
@dmitshur dmitshur changed the title WIP: Fix support for empty diffs (new, deleted, renamed files). Fix support for empty diffs (new, deleted, renamed files). May 13, 2016
@dmitshur dmitshur changed the title Fix support for empty diffs (new, deleted, renamed files). Fix support for empty diffs (new, deleted, renamed, binary files). May 13, 2016
@dmitshur
Copy link
Contributor Author

With the latest commit bcc6326, I've finished cleaning up. This PR is ready for final review and merging (commits need to be squashed before merging).

There are situations where a diff is empty. For example, if a blank
file is added a removed. Or if a file is renamed without any changes.
This change detects and handles those situations properly. That
includes fixing support for modified binary files.

Improve test coverage significantly.

Fixes #10.

diff.Hunks = nil
if got, want := diff, test.wantDiff; !reflect.DeepEqual(got, want) {
t.Errorf("%s:\n\ngot: %v\nwant: %v", test.filename, goon.Sdump(got), goon.Sdump(want))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could consider using github.com/d4l3k/messagediff here instead of printing 2 goons. It might be even more readable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever you think is best; this is just a test dependency so adding dependencies is fine.

@beyang
Copy link
Member

beyang commented May 17, 2016

@shurcooL does this need to be code reviewed? If so, can you assign it to someone?

@dmitshur
Copy link
Contributor Author

dmitshur commented May 17, 2016

I'm quite confident about this change, but it needs to be reviewed because it's standard practice that we use. I've assigned @slimsag since he has most context (he worked on it in #10 (comment)).

@emidoots
Copy link
Member

LGTM

@dmitshur dmitshur merged commit 9bc7549 into master May 20, 2016
@dmitshur dmitshur deleted the fix-empty-diffs branch May 20, 2016 19:01
dmitshur added a commit to shurcooL-legacy/Conception-go that referenced this pull request May 21, 2016
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.

Add support for parsing multi-file diffs affecting binary files.
3 participants