!21542 Part 2 & 3: Handle edge cases in stage and unstage mutations
What does this MR do?
Modify stage and unstage mutations to handle edge cases involving the ability to stage empty content in Web IDE. Also handle cases of files deleted and readded.
When staged changes and unstaged changes have exactly the same, but opposite changes, staging or unstaging at that point should cancel each other's change out. This is the default behaviour of git. This may happen by adding a string and then removing it, or by deleting a file competely and adding it back (by creating a new file and pasting its contents).
Current behaviour: On staging/unstaging a file that has equal, but opposite changes in staged and unstaged, an empty changeset is added to staged/unstaged changes respectively.
Expected behavior: There should be no changeset, since the staged and unstaged changes cancel each other out.
This MR is the second and third part (combined) of the breakdown of MR !21542 (closed) and a fix for issue #39498 (closed).
This MR uses the getters defined in !21673 (merged).
Update:
This MR now includes the changes of !21675 (closed) in it too. The changes in this MR and !21675 (closed) both depend on each other and will cause regressions if merged without each other.
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team