Allow empty parent diffs

Review Request #10122 — Created Aug. 20, 2018 and submitted — Latest diff uploaded

Information

Review Board
release-3.0.x
397fea1...

Reviewers

If a review request was uploaded with a FileDiff that contained a
parent diff that creates a 0 byte file, we would previously be unable to
generate the pre-patch file due to a limitation of patch(1). To work
around this, when we encounter a specific error from patch (that is,
when it only finds what it considers garbage in the input), we check to
see if the parent diff is empty and if so we return an empty buffer.
Future calls will get_original_file for that file will have no extra
database query overhead as the results of this (which costs at least two
queries) will be cached with the FileDiff.

  • Ran unit tests.
  • Uploaded a commit that contained a FileDiff that created a 0 byte
    file. With this patch applied, I was able to view the diff.
    Loading...