MR diff/changes view shows old commits/changes
Please note, this issue has been promoted to an epic: &854 (closed)
See @jramsay's note: #15140 (comment 150463416)
There are situations where a change in the source branch that is already present in the target branch is shown in the merge request diff. This is confusing because the change is not actually being introduced in to the target branch because it is already there.
For example, a fix is added directly to master, then cherry picked in to the master branch, the cherry picked change will be visible in the merge request. (jramsay-reproduce/ce-15140!1 (diffs))
X---C' feature-a
/
A---B---C master
See comment https://gitlab.com/gitlab-org/gitlab-ce/issues/15140#note_11709832 below for detailed description of the current behavior.
GitLab should show the changes that will be merged in to the target branch.
MR diff/changes view shows commits/changes that have already been merged into target branch.
Steps to reproduce
For now I can't reproduce the issue consistently. It occurs randomly (and often, but not always) in our two main projects/repos. Haven't been able to reproduce it elsewhere yet.
The way our git process works is we have two long standing branches, nonprod and production. Production is marked as the default branch. We create new branches off/from production branch. Make the change in the new branch and submit two MRs, one to nonprod and one to production.
So clone -> production -> (create new branch) branch_example1
Then submit two MRs.
branch_example1 -> nonprod (the problem happens here)
branch_example1 -> production (the problem never happens here)
The bug is:
The diffs view (Changes) view for the nonprod MR is incorrect and differs from that of the production MR. It shows commits that aren't from the branch I created. These commits are always merge commits. The issue is that the diff view then shows changes/diffs for changes that aren't from the source branch. These "extra" changes have already been merged into the target branch. So the diff appears incorrect. The MR to the target production(default) branch is always correct/perfect. There are no extra merge commits and the diffs are always correct, ie just the things I changed/just the difference between the source and target branch. It doesn't show these extra invalid changes that have already been merged.
Only when this bug occurs does the title for the MR for the target nonprod be set to the branch name (with the underscores stripped and the title capitalised.) This differs from the target production(default) MR, that MR title is set to from the commit in the branch. This makes the MR overview screen confusing because one can't easily see the two MRs are the same, just to a different target.
Expected behaviour
Under the diffs/changes view on the MR, we would only see the diff/changes. (Currently it displays changes that are already present in the destination/target branch).
Secondly I'd expect the the MR title to be set consistently for both MRs with the same source branch (and same commits in the branch).
Possible fixes
No idea.
I'm not quite sure how can I debug this further.
We used this branching strategy on Stash before and never had this issue. We also imported this repo and git history/data from Stash.
I'll attempt to debug this further.