Skip to content

Use git2go merge for squashing

Piotr Stankowski requested to merge trakos/gitaly:squash-using-merge into master

This MR should resolve gitlab#352581 (closed). It will be rolled out with #4213 (closed).

I am introducing a new feature flag: squash_using_merge. With this flag enabled, squashes are performed using git2go merge instead of performing rebase and git commit-tree.

The scenario that is problematic for rebase and git commit-tree looks like this:

  1. Create a new branch source with a commit modifying file A.
  2. Create a new commit on main branch that modifies the same line in a file A, creating a conflict.
  3. Merge main into source, resolving the conflict.
  4. Create a new commit on main branch that does not introduce any new conflicts.

The check for mergeability passes, as it uses regular merge to check. However, when squashing with rebase and git commit-tree, we raise an error. It first tries to rebase source onto main, commit-by-commit, so it encounters the conflict again and cannot proceed any further.

With new proposed method that uses git2go merge to squash commits we will not encounter such problems. Every time a merge is possible, this squash will be possible as well, as it's equivalent to git merge --squash. The ability to squash using git2go merge was added in !4241 (merged).

Recordings

If you follow repro directions from gitlab#352581 (closed) description, on merge you get an error like this:

2022-05-01_10-24__Display__OC_Studio_

With this MR, gitlab!86302 (closed), and gitaly_squash_using_merge feature flag enabled, the same MR merges successfully:

2022-05-01_10-56__Display__OC_Studio_

Edited by Toon Claes

Merge request reports