"Compare" shows no diff in include-target-changes mode

Summary

When using the Compare Revisions page, enabling “Include changes to target after source was created” produces “There isn't anything to compare”, even though git diff <source>..<target> in a local repo correctly shows differences.

This indicates a mismatch between GitLab’s compare logic and native git diff.

Compare Revisions Page git diff command
image image

Steps to reproduce

  1. Create a new branch test-compare based on main.
  2. Make a simple commit on test-compare (e.g., change a line of text) and push it.
  3. Go to the GitLab Compare page.
  4. Set Source=main, Target=test-compare
  5. Enable the checkbox: “Include changes to target after source was created”.
  6. Click Compare.
  7. Observe that GitLab displays: “There isn't anything to compare”
  8. Run the equivalent command locally:
    git fetch
    git diff test-compare..main # Local diff shows actual content changes.

Example Project

test-mirror-ui/project1@test-compare..main

What is the current bug behavior?

The Compare page shows no diff (“There isn't anything to compare”) even though the two branches have differences.

Swapping the Source/Target order sometimes makes the diff appear, which suggests the data is correct but the internal logic or rendering path is incorrect.

Local git diff consistently shows the expected diff.

What is the expected correct behavior?

With “Include changes to target after source was created” enabled, GitLab should behave like:

git diff <source> <target>
# or equivalently
git diff <source>..<target>

and display all differences between the two branch tips, regardless of direction.

Relevant logs and/or screenshots

The screenshot is provided above.

Edited by 🤖 GitLab Bot 🤖