diff: Count added and removed lines when parsing patch body

In #7067 (comment 3075876711), a suggestion was raised to include a count of added and removed lines in the response fields for the CommitDiff and DiffBlobs RPCs. They currently don't include these fields, which means that callers need to either manually parse the patch body sent by Gitaly, or execute the DiffStats RPC to retrieve only the counts. DiffStats simply executes git-diff(1) with the --numstat argument to only produce the counts.

As explained in the above thread, the p95 latency of DiffStats is ~40ms. Since we already go to the trouble of asking Git to produce a diff, we can modify our diff parser to count the lines and return them in the response.

Refer to the commit messages for more information.

Merge request reports

Loading
Loading