also looking at this
fix(merge): git replay takes --advance, not flags it never had
#3
1 file
+11
-14
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -81,27 +81,24 @@ export async function performMerge(path: string, input: MergeInput): Promise<Mer | ||
| 81 | 81 | * entirely on objects, with no index and no checkout. Anything else would mean |
| 82 | 82 | * checking out a copy of the repository on every merge. |
| 83 | 83 | * |
| 84 | * It is asked to print the ref update rather than apply it, so the ref still | |
| 85 | * moves through the same guarded `update-ref` as the other strategies. Some git | |
| 86 | * versions apply the update themselves by default, which would skip that guard | |
| 87 | * and let a merge overwrite a push that arrived a moment earlier. | |
| 84 | * `--advance` names the branch the commits are for, and replay only ever | |
| 85 | * *prints* the ref update - it never applies one - so the ref still moves | |
| 86 | * through the same guarded `update-ref` as the other strategies. The commits | |
| 87 | * are built on the branch's current tip; when that tip is no longer the | |
| 88 | * baseSha the rules were checked against, the guard below refuses, which is | |
| 89 | * the same answer the other strategies give to a push that arrived mid-merge. | |
| 88 | 90 | */ |
| 89 | 91 | async function performRebase( |
| 90 | 92 | path: string, |
| 91 | 93 | input: MergeInput, |
| 92 | 94 | env: Record<string, string>, |
| 93 | 95 | ): Promise<MergeResult> { |
| 94 | const range = [ | |
| 95 | `--onto=${input.baseSha}`, | |
| 96 | `--ref=refs/heads/${input.base}`, | |
| 96 | const replayed = await runGit(path, [ | |
| 97 | 'replay', | |
| 98 | '--advance', | |
| 99 | `refs/heads/${input.base}`, | |
| 97 | 100 | `${input.baseSha}..${input.headSha}`, |
| 98 | ] | |
| 99 | ||
| 100 | let replayed = await runGit(path, ['replay', '--ref-action=print', ...range], { env }) | |
| 101 | ||
| 102 | // Older git has no --ref-action because printing was all it ever did. | |
| 103 | if (!replayed.ok && /unknown option|unrecognized/i.test(replayed.stderr)) | |
| 104 | replayed = await runGit(path, ['replay', ...range], { env }) | |
| 101 | ], { env }) | |
| 105 | 102 | |
| 106 | 103 | if (!replayed.ok) |
| 107 | 104 | return { ok: false, error: replayed.stderr.trim() || 'the branch could not be replayed onto the base' } |