4 Merge commits $L$ and $R$ using merge base $M$:
6 C \hasparents \{ L, R \}
8 \patchof{C} = \patchof{L}
10 \commitmergeof{C}{L}{M}{R}
12 We will occasionally use $X,Y$ s.t. $\{X,Y\} = \{L,R\}$.
14 This can also be used for dependency re-insertion, by setting $L \in
15 \pn$, $R \in \pry$, $M = \baseof{R}$, provided that the Conditions are
16 satisfied; in particular, provided that $L \ge \baseof{R}$.
18 \subsection{Conditions}
19 \[ \eqn{ Ingredients }{
25 R \in \py : & \baseof{R} \ge \baseof{L}
26 \land [\baseof{L} = M \lor \baseof{L} = \baseof{M}] \\
27 R \in \pn : & M = \baseof{L} \\
28 \text{otherwise} : & \false
31 \[ \eqn{ Base Merge }{
38 ( R \in \pqy \land \pq \neq \p )
41 \[ \eqn{ Merge Acyclic }{
46 \[ \eqn{ Removal Merge Ends }{
47 X \not\haspatch \p \land
51 \pendsof{Y}{\py} = \pendsof{M}{\py}
53 \[ \eqn{ Addition Merge Ends }{
54 X \not\haspatch \p \land
55 M \nothaspatch \p \land
58 \bigforall_{E \in \pendsof{X}{\py}} E \le Y
61 \[ \eqn{ Suitable Tips }{
62 \bigforall_{\p \patchisin C, \; \py \neq \patchof{L}}
64 \pendsof{J}{\py} = \{ T \}
66 \forall_{E \in \pendsof{K}{\py}} T \ge E
67 , \text{where} \{J,K\} = \{L,R\}
69 \[ \eqn{ Foreign Merge }{
70 \isforeign{L} \implies \isforeign{R}
73 \subsection{Non-Topbloke merges}
75 We require both $\isforeign{L}$ and $\isforeign{R}$
76 (Foreign Merge, above).
77 I.e. not only is it forbidden to merge into a Topbloke-controlled
78 branch without Topbloke's assistance, it is also forbidden to
79 merge any Topbloke-controlled branch into any plain git branch.
81 Given those conditions, Tip Merge and Merge Acyclic do not apply.
82 By Foreign Ancestry of $L$, $\isforeign{M}$ as well.
83 So by Foreign Ancestry for any $A \in \{L,M,R\}$,
84 $\forall_{\p, D \in \py} D \not\le A$
85 so $\pendsof{A}{\py} = \{ \}$ and the RHS of both Merge Ends
86 conditions are satisifed.
88 So a plain git merge of non-Topbloke branches meets the conditions and
89 is therefore consistent with our model.
91 \subsection{No Replay}
93 By definition of \commitmergename,
94 $D \isin C \implies D \isin L \lor D \isin R \lor D = C$.
96 Ingredients Prevent Replay applies. $\qed$
98 \subsection{Unique Base}
100 Need to consider only $C \in \py$, ie $L \in \py$,
101 and calculate $\pendsof{C}{\pn}$. So we will consider some
102 putative ancestor $A \in \pn$ and see whether $A \le C$.
104 By Exact Ancestors for C, $A \le C \equiv A \le L \lor A \le R \lor A = C$.
105 But $C \in \py$ and $A \in \pn$ so $A \neq C$.
106 Thus $A \le C \equiv A \le L \lor A \le R$.
108 By Unique Base of L and Transitive Ancestors,
109 $A \le L \equiv A \le \baseof{L}$.
111 \subsubsection{For $R \in \py$:}
113 By Unique Base of $R$ and Transitive Ancestors,
114 $A \le R \equiv A \le \baseof{R}$.
116 But by Tip Merge condition on $\baseof{R}$,
117 $A \le \baseof{L} \implies A \le \baseof{R}$, so
118 $A \le \baseof{R} \lor A \le \baseof{L} \equiv A \le \baseof{R}$.
119 Thus $A \le C \equiv A \le \baseof{R}$.
120 That is, $\baseof{C} = \baseof{R}$.
122 \subsubsection{For $R \in \pn$:}
124 By Tip Merge condition and since $M \le R$,
125 $A \le \baseof{L} \implies A \le R$, so
126 $A \le R \lor A \le \baseof{L} \equiv A \le R$.
127 Thus $A \le C \equiv A \le R$.
128 That is, $\baseof{C} = R$.
132 \subsection{Coherence and Patch Inclusion}
136 C \haspatch \p \lor C \nothaspatch \p
138 C \haspatch \p \equiv
139 \stmtmergeof{L \haspatch \p}{M \haspatch \p}{R \haspatch \p}
141 which (given Coherence of $L$,$M$,$R$) is equivalent to
144 L \nothaspatch \p \land R \nothaspatch \p : & C \nothaspatch \p \\
145 L \haspatch \p \land R \haspatch \p : & C \haspatch \p \\
146 \text{otherwise} \land M \haspatch \p : & C \nothaspatch \p \\
147 \text{otherwise} \land M \nothaspatch \p : & C \haspatch \p
151 ~ Consider $D \in \py$.
153 \subsubsection{For $L \nothaspatch \p, R \nothaspatch \p$:}
154 $D \not\isin L \land D \not\isin R$. $C \not\in \py$ (otherwise $L
155 \in \py$ ie $L \haspatch \p$ by Tip Own Contents for $L$).
157 Applying \commitmergename\ gives $D \not\isin C$ i.e. $C \nothaspatch \p$.
160 \subsubsection{For $L \haspatch \p, R \haspatch \p$:}
161 $D \isin L \equiv D \le L$ and $D \isin R \equiv D \le R$.
162 (Likewise $D \isin X \equiv D \le X$ and $D \isin Y \equiv D \le Y$.)
164 Consider $D = C$: $D \isin C$, $D \le C$, OK for $C \zhaspatch \p$.
166 For $D \neq C$: $D \le C \equiv D \le L \lor D \le R
167 \equiv D \isin L \lor D \isin R$.
168 (Likewise $D \le C \equiv D \le X \lor D \le Y$.)
170 Consider $D \neq C, D \isin X \land D \isin Y$:
171 By \commitmergename, $D \isin C$. Also $D \le X$
172 so $D \le C$. OK for $C \zhaspatch \p$.
174 Consider $D \neq C, D \not\isin X \land D \not\isin Y$:
175 By \commitmergename, $D \not\isin C$.
176 And $D \not\le X \land D \not\le Y$ so $D \not\le C$.
177 OK for $C \zhaspatch \p$.
179 Remaining case, wlog, is $D \not\isin X \land D \isin Y$.
180 $D \not\le X$ so $D \not\le M$ so $D \not\isin M$.
181 Thus by \commitmergename, $D \isin C$. And $D \le Y$ so $D \le C$.
182 OK for $C \zhaspatch \p$.
184 So, in all cases, $C \zhaspatch \p$.
185 And by $L \haspatch \p$, $\exists_{F \in \py} F \le L$
186 and this $F \le C$ so indeed $C \haspatch \p$.
188 \subsubsection{For (wlog) $X \not\haspatch \p, Y \haspatch \p$:}
190 One of the Merge Ends conditions applies.
191 Recall that we are considering $D \in \py$.
192 $D \isin Y \equiv D \le Y$. $D \not\isin X$.
193 We will show for each of
195 if $M \haspatch \p$, $D \not\isin C$,
196 whereas if $M \nothaspatch \p$, $D \isin C \equiv D \le C$.
197 And by $Y \haspatch \p$, $\exists_{F \in \py} F \le Y$ and this
198 $F \le C$ so this suffices.
200 Consider $D = C$: Thus $C \in \py, L \in \py$.
201 By Tip Own Contents, $L \haspatch \p$ so $L \neq X$,
202 therefore we must have $L=Y$, $R=X$.
203 Conversely $R \not\in \py$
204 so by Tip Merge $M = \baseof{L}$. Thus $M \in \pn$ so
205 by Base Acyclic $M \nothaspatch \p$. By \commitmergename, $D \isin C$,
208 Consider $D \neq C, M \nothaspatch \p, D \isin Y$:
209 $D \le Y$ so $D \le C$.
210 $D \not\isin M$ so by \commitmergename, $D \isin C$. OK.
212 Consider $D \neq C, M \nothaspatch \p, D \not\isin Y$:
213 $D \not\le Y$. If $D \le X$ then
214 $D \in \pancsof{X}{\py}$, so by Addition Merge Ends and
215 Transitive Ancestors $D \le Y$ --- a contradiction, so $D \not\le X$.
216 Thus $D \not\le C$. By \commitmergename, $D \not\isin C$. OK.
218 Consider $D \neq C, M \haspatch \p, D \isin Y$:
219 $D \le Y$ so $D \in \pancsof{Y}{\py}$ so by Removal Merge Ends
220 and Transitive Ancestors $D \in \pancsof{M}{\py}$ so $D \le M$.
221 Thus $D \isin M$. By \commitmergename, $D \not\isin C$. OK.
223 Consider $D \neq C, M \haspatch \p, D \not\isin Y$:
224 By \commitmergename, $D \not\isin C$. OK.
228 \subsection{Base Acyclic}
230 This applies when $C \in \pn$.
231 $C \in \pn$ when $L \in \pn$ so by Merge Acyclic, $R \nothaspatch \p$.
233 Consider some $D \in \py$.
235 By Base Acyclic of $L$, $D \not\isin L$. By the above, $D \not\isin
236 R$. And $D \neq C$. So $D \not\isin C$.
240 \subsection{Tip Contents}
242 We need worry only about $C \in \py$.
243 And $\patchof{C} = \patchof{L}$
244 so $L \in \py$ so $L \haspatch \p$. We will use the Unique Base
245 of $C$, and its Coherence and Patch Inclusion, as just proved.
247 Firstly we show $C \haspatch \p$: If $R \in \py$, then $R \haspatch
248 \p$ and by Coherence/Inclusion $C \haspatch \p$ . If $R \not\in \py$
249 then by Tip Merge $M = \baseof{L}$ so by Base Acyclic and definition
250 of $\nothaspatch$, $M \nothaspatch \p$. So by Coherence/Inclusion $C
251 \haspatch \p$ (whether $R \haspatch \p$ or $\nothaspatch$).
253 We will consider an arbitrary commit $D$
254 and prove the Exclusive Tip Contents form.
256 \subsubsection{For $D \in \py$:}
257 $C \haspatch \p$ so by definition of $\haspatch$, $D \isin C \equiv D
260 \subsubsection{For $D \not\in \py, R \not\in \py$:}
262 $D \neq C$. By Tip Contents of $L$,
263 $D \isin L \equiv D \isin \baseof{L}$, so by Tip Merge condition,
264 $D \isin L \equiv D \isin M$. So by \commitmergename, $D \isin
265 C \equiv D \isin R$. And $R = \baseof{C}$ by Unique Base of $C$.
266 Thus $D \isin C \equiv D \isin \baseof{C}$. OK.
268 \subsubsection{For $D \not\in \py, R \in \py$:}
273 $D \isin L \equiv D \isin \baseof{L}$ and
274 $D \isin R \equiv D \isin \baseof{R}$.
276 Apply Tip Merge condition.
277 If $\baseof{L} = M$, trivially $D \isin M \equiv D \isin \baseof{L}.$
278 Whereas if $\baseof{L} = \baseof{M}$, by definition of $\base$,
279 $\patchof{M} = \patchof{L} = \py$, so by Tip Contents of $M$,
280 $D \isin M \equiv D \isin \baseof{M} \equiv D \isin \baseof{L}$.
282 So $D \isin M \equiv D \isin L$ so by \commitmergename,
283 $D \isin C \equiv D \isin R$. But from Unique Base,
284 $\baseof{C} = \baseof{R}$.
285 Therefore $D \isin C \equiv D \isin \baseof{C}$. OK.
289 \subsection{Unique Tips}
291 For $L \in \py$, trivially $\pendsof{C}{\py} = C$ so $T = C$ is
294 For $L \not\in \py$, $\pancsof{C}{\py} = \pancsof{L}{\py} \cup
295 \pancsof{R}{\py}$. So $T$ from Suitable Tips is a suitable $T$ for
300 \subsection{Foreign Inclusion}
302 Consider some $D \in \foreign$.
303 By Foreign Inclusion of $L, M, R$:
304 $D \isin L \equiv D \le L$;
305 $D \isin M \equiv D \le M$;
306 $D \isin R \equiv D \le R$.
308 \subsubsection{For $D = C$:}
310 $D \isin C$ and $D \le C$. OK.
312 \subsubsection{For $D \neq C, D \isin M$:}
314 Thus $D \le M$ so $D \le L$ and $D \le R$ so $D \isin L$ and $D \isin
315 R$. So by \commitmergename, $D \isin C$. And $D \le C$. OK.
317 \subsubsection{For $D \neq C, D \not\isin M, D \isin X$:}
319 By \commitmergename, $D \isin C$.
320 And $D \isin X$ means $D \le X$ so $D \le C$.
323 \subsubsection{For $D \neq C, D \not\isin M, D \not\isin L, D \not\isin R$:}
325 By \commitmergename, $D \not\isin C$.
326 And $D \not\le L, D \not\le R$ so $D \not\le C$.
331 \subsection{Foreign Ancestry}
333 Only relevant if $\isforeign{L}$, in which case
334 $\isforeign{C}$ and by Foreign Merge $\isforeign{R}$,
335 so Totally Foreign Ancestry applies. $\qed$
337 \subsection{Bases' Children}
339 If $L \in \py, R \in \py$: not applicable for either $D=L$ or $D=R$.
341 If $L \in \py, R \in \pn$: not applicable for $L$, OK for $R$.
343 Other possibilities for $L \in \py$ are excluded by Tip Merge.
345 If $L \in \pn, R \in \pn$: satisfied for both $L$ and $R$.
347 If $L \in \pn, R \in \foreign$: satisfied for $L$, not applicable for
350 If $L \in \pn, R \in \pqy$: satisfied for $L$, not applicable for
353 Other possibilities for $L \in \pn$ are excluded by Base Merge.
355 If $L \in \foreign$: not applicable for $L$; nor for $R$, by Foreign Merge.