Compare should diff commits, not the merge base

Summary

The diff output of the Compare feature does not show all differing lines.

Steps to reproduce

  1. Clone https://gitlab.com/jssfr/diffsample
  2. git diff bob..alice
  3. Compare the git diff output with the GitLab compare output when using alice as source and bob as target.

Example Project

What is the current bug behavior?

Some content from the diff is missing. Specifically, the copy the bytes comment is not found in the GitLab compare view, while git diff shows it.

What is the expected correct behavior?

GitLab should not omit changed lines from a diff.

Relevant logs and/or screenshots

With git diff:

diff --git a/code.c b/code.c
index 37ea888..cfe8f2e 100644
--- a/code.c
+++ b/code.c
@@ -1,15 +1,14 @@
-void Chunk_copy(Chunk *src, size_t src_start, Chunk *dst, size_t dst_start, size_t n)
+int Chunk_bounds_check(Chunk *chunk, size_t start, size_t n)
 {
-    if (!Chunk_bounds_check(src, src_start, n)) return;
-    if (!Chunk_bounds_check(dst, dst_start, n)) return;
+    if (chunk == NULL) return 0;

-    // copy the bytes
-    memcpy(dst->data + dst_start, src->data + src_start, n);
+    return start <= chunk->length && n <= chunk->length - start;
 }

-int Chunk_bounds_check(Chunk *chunk, size_t start, size_t n)
+void Chunk_copy(Chunk *src, size_t src_start, Chunk *dst, size_t dst_start, size_t n)
 {
-    if (chunk == NULL) return 0;
+    if (!Chunk_bounds_check(src, src_start, n)) return;
+    if (!Chunk_bounds_check(dst, dst_start, n)) return;

-    return start <= chunk->length && n <= chunk->length - start;
+    memcpy(dst->data + dst_start, src->data + src_start, n);
 }

With GitLab compare (click on the screenshot to get to the Compare page of the example project right away):

Screen_Shot_2019-09-02_at_13.48.59

(jssfr/diffsample@bob...alice)

Output of checks

This bug happens on GitLab.com (in addition to our self-hosted GitLab CE 11.x).

Acknowledgements and notes

Edited by James Ramsay (ex-GitLab)