Fix parsing git diffs with binary changes.
Review Request #4477 — Created Aug. 22, 2013 and submitted — Latest diff uploaded
Fix parsing git diffs with binary changes. Git diffs containing binary changes could appear as empty files if they're the last file in the diff. This was due to how the _is_empty_change code worked. It assumed there was at least 3 more lines in the file to work with, and if not, it would assume the change was empty. Binary changes appearing at the end of the file would fail this test. That function is now gone. Instead, we do an initial check that we're not at the end of the file, before parsing content, and then we keep an empty_change state around. It defaults to True, but if we find any diff content or a binary file, we set it to False. We use this state to determine, at the end of the function, what to return.
Tested uploading a change containing a normal file and then a binary file, in that order, without problems. Previously, the binary file would go missing. If it appeared first, it would work fine. Unit tests pass.