Changes incorrectly counted on merge request for squashed/deleted branch.
Summary
Merge Request changes tab incorrectly shows the total count of changes.
The actual changes included are correct, and the end result in the merged branch is correct.
The issue is specifically reproducible when removing/adding changes directly into master that replace/coincide with the changes in the branch.
Steps to reproduce
# Example Project
# https://gitlab.com/davinwalker/336351-incorrect-changes
# Main
echo "main branch" > main.txt
git add .
git commit -m "Initial Commit (Main)"
git push
# Branch
git checkout -b 'branch'
echo -e "bad" > problem.txt
git add .
git commit -m "Problem File Commit (Branch)"
date > branch_changes.txt
git add .
git commit -m "Random Changes (Branch)"
git push origin branch -o merge_request.title='Initial MR' -o merge_request.create
# Review MR / Don't Merge
# https://gitlab.com/davinwalker/336351-incorrect-changes/-/merge_requests/1
# - 2 Changes
# Back to Main
git checkout main
echo -e "bad" > problem.txt
git add .
git commit -m "Problem main File Commit (Main)"
git push
# Back to MR #1, Squash, Delete Branch, Merge
# - Showing 2 Changes, 'Changes' only shows the one change.
# https://gitlab.com/davinwalker/336351-incorrect-changes/-/merge_requests/1
# Back to Branch
git checkout 'branch'
git rm problem.txt
git commit -m 'Remove Problem File (Branch)'
git push origin branch -o merge_request.title='Second MR' -o merge_request.create
# Review Merge #2
# - 1 Change, with 'no changes between branch and main'
# - Merge without squash will include commit history without removing files
Example Project
Reproduced in this Project: https://gitlab.com/davinwalker/336351-incorrect-changes
What is the current bug behavior?
When the first MR is created, the 'total' changes is correct (2):
After the changes are made to the main branch, the changes still incorrectly show 2:
After merging, squashing, then pushing the commits up again the second MR is also showing an incorrect change count:
What is the expected correct behavior?
Reflect the count of changes that will be made into the target branch.
Customer reported on ZD Internal Ticket