•  
      request #31081 Pull request shows wrong diff in "Changes"
    Infos
    #31081
    Thorsten Hackbarth (thorsten)
    2023-04-17 14:32
    2023-02-20 15:11
    32686
    Details
    Pull request shows wrong diff in "Changes"

    Pull requests show the changes against a common base not against the selected destination.

    How to reproduce

    • Create 2 branches from main branch
    • Make a change in branch_1; commit and push
    • Make a change in the same line in branch_2; commit and push
    • Crate pull request with branch_2 as source and branch_1 as destination

    Go to <Changes> and find out that the diff shows changes branch_2 vs. main branch which is different from changes branch_2 vs. branch_1.

    More explanations here: https://forum.gitlab.com/t/merge-requests-not-showing-correct-diff-against-master/60985 and here https://gitlab.com/gitlab-org/gitlab-foss/-/issues/15140#note_11709832

    Pull Request
    14.5
    Empty
    • [ ] enhancement
    • [ ] internal improvement
    Empty
    Stage
    Empty
    New
    Empty
    Attachments
    References
    Referencing request #31081

    Follow-ups

    User avatar
    Martin GOYOT (goyotm)2023-04-17 14:32

    In attachement, please find a Git repository to reproduce the issue. It has two branches, create a pull request to merge new-branch into main, this will show the issue.

    There are two branches with three commits each :

    * main
       * initial commit
       * a common change
       * a change on main only

    * new-branch
       * initial commit
       * a common change
       * a new branch change

    The only diverging commits are a change on main only and a new branch change. When creating a pull request to merge new-branch into main, it appears that the change section shows a diff of a new branch change against a common change instead of a new branch change against a change on main only.

    Hence, we get something that looks like:

    2551-image%281%29.png

    While we are expecting something that should look like:

    2552-image.png