Cannot do a diff between revisions of the same branch

Summary

The per-project compare page allows the input of two SHA1, but clicking on the compare button returns this message:

There isn't anything to compare.
You'll need to use different branch names to get a valid comparison.

However, comparing from an old commit on master to master itself gives the expected result (all the commits from the old commit to the HEAD of master are shown), so it seems that the functionality is there.

Steps to reproduce

For a given project, go to Repository > Compare and choose any two commits on a given branch, then click the Compare button.

Example Project

Here's an example on the Gitlab CE repo itself: https://gitlab.com/gitlab-org/gitlab-ce/compare/294310f357532dd18cb8db4bd0e9aa7fb8c3a077...da844cb53857cfe6d12e3d9bf651e57ad8ce8782

What is the current bug behavior?

I'm getting the aforementioned error message

What is the expected correct behavior?

A per-file diff between the two revisions is shown.

Output of checks

I noticed this issue on a local Gitlab 9.5.4 install, but the problem also happens on GitLab.com