Branches and merges
What a merge of two branches does to the oplog, and how the oplog’s form decides what a merge can be resolved by.
When two branches change the oplog
Two branches that each add ops after the same op merge into an oplog
where two ops share one prev=: a fork. git’s merge=union rule
keeps both sides’ lines, so no op is lost. What is lost is the order.
When the two sides’ changes are independent, either order builds the
same schema. When they are not, such as two branches that each rename
the same table, the two orders build different schemas. So snapshot,
migrate and data list refuse a range that holds a fork, and
reconcile is where the order is chosen: it rewrites prev= into one
chain, and every op keeps its id. A sealed side always goes first.
Merge branches that change the oplog has the steps, and
retrofit reconcile has the flags and every refusal a
merge can produce.
The two forms
The oplog’s fourth header line, # retrofit-oplog-form:, names its
form: merge or compact. schema create writes merge unless given
--form compact, and schema form prints or switches it. The two forms
differ in what an edit leaves in the file, and that decides what a merge
of two branches can be resolved by.
- The merge form never deletes a line.
op revisewrites the new line withreplaces=naming the operation it retires, andop removeleaves a tombstone, the line with~before its operator. Each edit is a line of its own, so a file holding both sides’ lines still says what each side did, and keeping both sides of a conflict resolves it. - The compact form is for one line of work. It edits a line in place and deletes a removed one. An edit leaves no line of its own, so a file holding both sides’ lines brings back what one side revised or removed. Keeping both sides resolves only a hunk where both sides only appended; anywhere else the file is written from its three versions, the merge base, main’s and the branch’s (Bring main in with the three files).
What each path promises lists what each form gives through each git and host path, and the history checks a pull request runs differ by form.