Merge Trains allow immediate merge on outdated branches that use semi-linear history

Summary

On projects where Merge Trains are used where "Allow skipping the merge train" is disabled and the Merge method is set to "Merge commit with semi-linear history" it is possible to merge a merge request immediately, even though it's not up-to-date with the target branch.

Steps to reproduce

Have a project where:

  • Merge Trains is enabled
  • Merge method is set to "Merge commit with semi-linear history"
  • "Allow skipping the merge train" is disabled (or the merge_trains_skip_train Feature Flag is disabled)

In there create a merge request that's not up-to-date with the target branch (so it can be some commits behind). You'll then be presented with the "Merge immediately" option.

You are then able to merge the merge request, even though it's not up-to-date with the target branch.

If the general "Merge" option is used" it properly gets rebased as part of the Merge Train.

Example Project

None since this requires GitLab Premium which I only have on our self-hosted instance.

What is the current bug behavior?

I am able to merge a merge request that's not up-to-date with the target branch, even though semi-linear history is enabled, which requires merge requests to be up-to-date with the target branch.

What is the expected correct behavior?

I should not be presented with the "Merge immediately" option (when the "Allow skipping the merge train" option is disabled).

Or even better would be that "merge immediately" triggers a rebase. That's covered by #429009.

Relevant logs and/or screenshots

Screenshot_2025-10-03_at_15.10.13

Screenshot_2025-10-03_at_15.10.38

Output of checks

Results of GitLab environment info

System information
System:         Ubuntu 22.04
Proxy:          no
Current User:   git
Using RVM:      no
Ruby Version:   3.2.8
Gem Version:    3.6.9
Bundler Version:2.7.1
Rake Version:   13.0.6
Redis Version:  7.2.10
Sidekiq Version:7.3.9
Go Version:     unknown

GitLab information
Version:        18.3.3-ee
Revision:       c29534a7999
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     16.10
URL:            <snip>
HTTP Clone URL: <snip>
SSH Clone URL:  <snip>
Elasticsearch:  yes
Geo:            no
Using LDAP:     no
Using Omniauth: yes
Omniauth Providers: google_oauth2, gitlab

GitLab Shell
Version:        14.45.2
Repository storages:
- default:      unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell

Gitaly
- default Address:      unix:/var/opt/gitlab/gitaly/gitaly.socket
- default Version:      18.3.3
- default Git Version:  2.50.1.gl1

Results of GitLab application Check

Expand for output related to the GitLab application check
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 14.45.2 ? ... OK (14.45.2)
Running /opt/gitlab/embedded/service/gitlab-shell/bin/gitlab-shell-check
Internal API available: OK
Redis available via internal API: OK
gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes
Number of Sidekiq processes (cluster/worker) ... 1/2

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Checking Reply by email ...

IMAP server credentials are correct? ... Checking <snip>
yes
Mailroom enabled? ... skipped
MailRoom running? ... skipped

Checking Reply by email ... Finished


Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Database config exists? ... yes
Tables are truncated? ... skipped
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config up to date? ... yes
Cable config exists? ... yes
Resque config exists? ... yes
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory exists? ... yes
Uploads directory has correct permissions? ... yes
Uploads directory tmp has correct permissions? ... yes
Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units)
Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units)
Projects have namespace: ...
10/10 ... yes
10/11 ... yes
10/12 ... yes
10/13 ... yes
9/20 ... yes
9/24 ... yes
9/28 ... yes
10/30 ... yes
10/37 ... yes
9/42 ... yes
10/43 ... yes
9/44 ... yes
9/55 ... yes
9/57 ... yes
30/58 ... yes
3/59 ... yes
3/60 ... yes
3/61 ... yes
3/62 ... yes
3/63 ... yes
3/65 ... yes
30/66 ... yes
30/67 ... yes
30/68 ... yes
30/69 ... yes
3/70 ... yes
3/71 ... yes
3/72 ... yes
3/73 ... yes
3/74 ... yes
3/75 ... yes
3/76 ... yes
3/77 ... yes
3/78 ... yes
3/80 ... yes
3/81 ... yes
3/82 ... yes
3/83 ... yes
3/84 ... yes
3/85 ... yes
3/86 ... yes
3/87 ... yes
3/88 ... yes
3/89 ... yes
3/90 ... yes
3/91 ... yes
3/93 ... yes
3/94 ... yes
3/95 ... yes
3/96 ... yes
3/98 ... yes
3/103 ... yes
3/104 ... yes
3/105 ... yes
3/107 ... yes
3/113 ... yes
20/114 ... yes
31/115 ... yes
9/116 ... yes
3/117 ... yes
48/118 ... yes
9/119 ... yes
48/120 ... yes
48/121 ... yes
8/123 ... yes
20/124 ... yes
9/126 ... yes
106/127 ... yes
10/128 ... yes
10/129 ... yes
9/130 ... yes
3/131 ... yes
3/132 ... yes
16/133 ... yes
109/136 ... yes
10/137 ... yes
28/138 ... yes
9/140 ... yes
3/142 ... yes
60/143 ... yes
109/144 ... yes
109/145 ... yes
10/146 ... yes
109/147 ... yes
9/149 ... yes
3/150 ... yes
3/151 ... yes
3/152 ... yes
9/154 ... yes
3/155 ... yes
9/156 ... yes
109/157 ... yes
3/158 ... yes
3/159 ... yes
90/160 ... yes
90/161 ... yes
90/162 ... yes
90/163 ... yes
3/164 ... yes
2/166 ... yes
10/167 ... yes
9/168 ... yes
9/169 ... yes
109/170 ... yes
3/171 ... yes
3/177 ... yes
109/178 ... yes
10/179 ... yes
60/180 ... yes
9/182 ... yes
3/183 ... yes
3/184 ... yes
3/185 ... yes
20/186 ... yes
9/187 ... yes
2/188 ... yes
109/191 ... yes
3/192 ... yes
3/193 ... yes
106/195 ... yes
17/196 ... yes
95/199 ... yes
169/200 ... yes
9/202 ... yes
109/203 ... yes
109/204 ... yes
3/205 ... yes
106/208 ... yes
147/210 ... yes
147/211 ... yes
66/212 ... yes
106/213 ... yes
10/214 ... yes
9/216 ... yes
19/218 ... yes
19/219 ... yes
3/220 ... yes
3/221 ... yes
17/222 ... yes
8/226 ... yes
3/227 ... yes
3/228 ... yes
67/231 ... yes
66/233 ... yes
20/234 ... yes
8/236 ... yes
93/237 ... yes
109/238 ... yes
19/239 ... yes
171/241 ... yes
162/243 ... yes
128/246 ... yes
60/247 ... yes
185/251 ... yes
9/252 ... yes
17/254 ... yes
19/259 ... yes
9/261 ... yes
164/262 ... yes
196/263 ... yes
185/264 ... yes
162/265 ... yes
162/266 ... yes
106/268 ... yes
106/269 ... yes
9/270 ... yes
211/271 ... yes
185/272 ... yes
211/273 ... yes
169/274 ... yes
211/275 ... yes
101/277 ... yes
185/278 ... yes
3/279 ... yes
162/280 ... yes
201/282 ... yes
3/283 ... yes
169/284 ... yes
106/285 ... yes
9/288 ... yes
3/290 ... yes
169/291 ... yes
231/296 ... yes
231/300 ... yes
231/301 ... yes
231/302 ... yes
231/303 ... yes
219/304 ... yes
231/305 ... yes
231/306 ... yes
231/307 ... yes
219/308 ... yes
219/309 ... yes
219/311 ... yes
219/312 ... yes
219/316 ... yes
219/317 ... yes
219/318 ... yes
219/319 ... yes
9/323 ... yes
150/324 ... yes
219/325 ... yes
3/327 ... yes
3/328 ... yes
211/329 ... yes
109/331 ... yes
106/332 ... yes
3/333 ... yes
169/334 ... yes
219/337 ... yes
234/339 ... yes
164/340 ... yes
250/341 ... yes
250/342 ... yes
3/344 ... yes
226/345 ... yes
226/347 ... yes
219/349 ... yes
211/351 ... yes
3/352 ... yes
219/353 ... yes
219/354 ... yes
250/355 ... yes
3/356 ... yes
3/357 ... yes
3/359 ... yes
3/361 ... yes
267/362 ... yes
242/363 ... yes
93/364 ... yes
3/365 ... yes
3/366 ... yes
162/367 ... yes
231/368 ... yes
9/369 ... yes
9/370 ... yes
9/371 ... yes
20/372 ... yes
3/375 ... yes
3/376 ... yes
169/377 ... yes
219/378 ... yes
260/379 ... yes
3/380 ... yes
219/381 ... yes
3/382 ... yes
66/383 ... yes
219/385 ... yes
3/387 ... yes
219/389 ... yes
219/390 ... yes
219/391 ... yes
9/392 ... yes
271/394 ... yes
270/395 ... yes
2/396 ... yes
22/398 ... yes
219/400 ... yes
77/401 ... yes
219/402 ... yes
142/403 ... yes
219/404 ... yes
219/406 ... yes
658/407 ... yes
106/408 ... yes
3/410 ... yes
169/411 ... yes
19/413 ... yes
9/414 ... yes
219/415 ... yes
219/416 ... yes
219/417 ... yes
169/418 ... yes
219/419 ... yes
219/420 ... yes
219/421 ... yes
9/422 ... yes
3/423 ... yes
219/424 ... yes
219/425 ... yes
219/426 ... yes
169/427 ... yes
219/429 ... yes
3/430 ... yes
9/431 ... yes
229/432 ... yes
219/433 ... yes
270/434 ... yes
219/435 ... yes
219/436 ... yes
106/437 ... yes
169/438 ... yes
9/439 ... yes
106/441 ... yes
211/443 ... yes
219/444 ... yes
106/445 ... yes
106/446 ... yes
211/447 ... yes
219/449 ... yes
106/450 ... yes
10/452 ... yes
93/453 ... yes
219/455 ... yes
3/456 ... yes
814/458 ... yes
219/459 ... yes
106/460 ... yes
106/461 ... yes
219/464 ... yes
2/467 ... yes
3/468 ... yes
3/469 ... yes
3/471 ... yes
3/474 ... yes
169/475 ... yes
219/476 ... yes
106/477 ... yes
2/478 ... yes
2/479 ... yes
270/480 ... yes
2/481 ... yes
106/482 ... yes
211/483 ... yes
10/484 ... yes
211/485 ... yes
875/486 ... yes
270/487 ... yes
19/488 ... yes
2/489 ... yes
2/490 ... yes
814/491 ... yes
3/492 ... yes
270/493 ... yes
270/494 ... yes
219/495 ... yes
3/496 ... yes
894/497 ... yes
875/499 ... yes
106/500 ... yes
106/501 ... yes
9/502 ... yes
106/503 ... yes
Redis version >= 6.2.14? ... yes
Ruby version >= 3.0.6 ? ... yes (3.2.8)
Git user has default SSH configuration? ... yes
Active users: ... 83
Is authorized keys file accessible? ... yes
GitLab configured to store new projects in hashed storage? ... yes
All projects are in hashed storage? ... yes
Elasticsearch version 7.x-9.x or OpenSearch version 1.x-3.x ... yes (elasticsearch 9.1.2)
All migrations must be finished before doing a major upgrade ... yes

Checking GitLab App ... Finished


Checking GitLab subtasks ... Finished

Possible fixes

None. 😞

Edited by 🤖 GitLab Bot 🤖