Skip to content

Auto-resolve other conflict scenarios when AllowConflicts is true

Patrick Bajao requested to merge pb-auto-resolve-conflicts-other-scenarios into master

In order to be able to show diffs on based on the merge ref, we need to be able to automatically resolve conflicts when UserMergeToRef is called with AllowConflicts set to true.

In this MR, the mergeSubcommand.resolveConflicts has been modified to handle scenarios wherein there is a missing side of a conflict (whether it's our, their or the ancestor). This update is needed so we can show the MR diff even if there are conflicts. All of the scenarios mentioned in &4893 (closed) are now being handled. Previously, we can only handle scenario 1.

Before this change, we try to git-merge-file (via conflicts.MergeFile) using 3 versions of a file from ancestor, our, and their but that fails when one of them does not exist. With this change, we only do that when 2 of them are present.

When 2 of those aren't present, we "manually" (in code) handle conflict resolution by keeping the changes in conflict.Their and rejecting other changes in conflict.Our and conflict.Ancestor as we don't want them to show up.

Related to gitlab#281162 (closed)

P.S. Changelog trailer has been added on the commit.

Edited by Patrick Bajao

Merge request reports