3 Merge commits $L$ and $R$ using merge base $M$:
5 C \hasparents \{ L, R \}
7 \patchof{C} = \patchof{L}
9 \commitmergeof{C}{L}{M}{R}
11 We will occasionally use $X,Y$ s.t. $\{X,Y\} = \{L,R\}$.
13 This can also be used for dependency re-insertion, by setting $L \in
14 \pn$, $R \in \pry$, $M = \baseof{R}$, provided that the Conditions are
15 satisfied; in particular, provided that $L \ge \baseof{R}$.
17 \subsection{Conditions}
18 \[ \eqn{ Ingredients }{
24 R \in \py : & \baseof{R} \ge \baseof{L}
25 \land [\baseof{L} = M \lor \baseof{L} = \baseof{M}] \\
26 R \in \pn : & M = \baseof{L} \\
27 \text{otherwise} : & \false
30 \[ \eqn{ Base Merge }{
40 \[ \eqn{ Merge Acyclic }{
45 \[ \eqn{ Removal Merge Ends }{
46 X \not\haspatch \p \land
50 \pendsof{Y}{\py} = \pendsof{M}{\py}
52 \[ \eqn{ Addition Merge Ends }{
53 X \not\haspatch \p \land
54 M \nothaspatch \p \land
57 \bigforall_{E \in \pendsof{X}{\py}} E \le Y
60 \[ \eqn{ Suitable Tips }{
61 \bigforall_{\p \neq \patchof{L}, \; C \haspatch \p}
63 \pendsof{J}{\py} = \{ T \}
65 \forall_{E \in \pendsof{K}{\py}} T \ge E
66 , \text{where} \{J,K\} = \{L,R\}
68 \[ \eqn{ Foreign Merges }{
69 \isforeign{L} \implies \isforeign{R}
72 \subsection{Non-Topbloke merges}
74 We require both $\isforeign{L}$ and $\isforeign{R}$
75 (Foreign Merges, above).
76 I.e. not only is it forbidden to merge into a Topbloke-controlled
77 branch without Topbloke's assistance, it is also forbidden to
78 merge any Topbloke-controlled branch into any plain git branch.
80 Given those conditions, Tip Merge and Merge Acyclic do not apply.
81 By Foreign Contents of $L$, $\isforeign{M}$ as well.
82 So by Foreign Contents for any $A \in \{L,M,R\}$,
83 $\forall_{\p, D \in \py} D \not\le A$
84 so $\pendsof{A}{\py} = \{ \}$ and the RHS of both Merge Ends
85 conditions are satisifed.
87 So a plain git merge of non-Topbloke branches meets the conditions and
88 is therefore consistent with our model.
90 \subsection{No Replay}
92 By definition of \commitmergename,
93 $D \isin C \implies D \isin L \lor D \isin R \lor D = C$.
95 Ingredients Prevent Replay applies. $\qed$
97 \subsection{Unique Base}
99 Need to consider only $C \in \py$, ie $L \in \py$,
100 and calculate $\pendsof{C}{\pn}$. So we will consider some
101 putative ancestor $A \in \pn$ and see whether $A \le C$.
103 By Exact Ancestors for C, $A \le C \equiv A \le L \lor A \le R \lor A = C$.
104 But $C \in \py$ and $A \in \pn$ so $A \neq C$.
105 Thus $A \le C \equiv A \le L \lor A \le R$.
107 By Unique Base of L and Transitive Ancestors,
108 $A \le L \equiv A \le \baseof{L}$.
110 \subsubsection{For $R \in \py$:}
112 By Unique Base of $R$ and Transitive Ancestors,
113 $A \le R \equiv A \le \baseof{R}$.
115 But by Tip Merge condition on $\baseof{R}$,
116 $A \le \baseof{L} \implies A \le \baseof{R}$, so
117 $A \le \baseof{R} \lor A \le \baseof{L} \equiv A \le \baseof{R}$.
118 Thus $A \le C \equiv A \le \baseof{R}$.
119 That is, $\baseof{C} = \baseof{R}$.
121 \subsubsection{For $R \in \pn$:}
123 By Tip Merge condition and since $M \le R$,
124 $A \le \baseof{L} \implies A \le R$, so
125 $A \le R \lor A \le \baseof{L} \equiv A \le R$.
126 Thus $A \le C \equiv A \le R$.
127 That is, $\baseof{C} = R$.
131 \subsection{Coherence and Patch Inclusion}
135 L \nothaspatch \p \land R \nothaspatch \p : & C \nothaspatch \p \\
136 L \haspatch \p \land R \haspatch \p : & C \haspatch \p \\
137 \text{otherwise} \land M \haspatch \p : & C \nothaspatch \p \\
138 \text{otherwise} \land M \nothaspatch \p : & C \haspatch \p
142 ~ Consider $D \in \py$.
144 \subsubsection{For $L \nothaspatch \p, R \nothaspatch \p$:}
145 $D \not\isin L \land D \not\isin R$. $C \not\in \py$ (otherwise $L
146 \in \py$ ie $L \haspatch \p$ by Tip Own Contents for $L$).
148 Applying \commitmergename gives $D \not\isin C$ i.e. $C \nothaspatch \p$.
151 \subsubsection{For $L \haspatch \p, R \haspatch \p$:}
152 $D \isin L \equiv D \le L$ and $D \isin R \equiv D \le R$.
153 (Likewise $D \isin X \equiv D \le X$ and $D \isin Y \equiv D \le Y$.)
155 Consider $D = C$: $D \isin C$, $D \le C$, OK for $C \zhaspatch \p$.
157 For $D \neq C$: $D \le C \equiv D \le L \lor D \le R
158 \equiv D \isin L \lor D \isin R$.
159 (Likewise $D \le C \equiv D \le X \lor D \le Y$.)
161 Consider $D \neq C, D \isin X \land D \isin Y$:
162 By \commitmergename, $D \isin C$. Also $D \le X$
163 so $D \le C$. OK for $C \zhaspatch \p$.
165 Consider $D \neq C, D \not\isin X \land D \not\isin Y$:
166 By \commitmergename, $D \not\isin C$.
167 And $D \not\le X \land D \not\le Y$ so $D \not\le C$.
168 OK for $C \zhaspatch \p$.
170 Remaining case, wlog, is $D \not\isin X \land D \isin Y$.
171 $D \not\le X$ so $D \not\le M$ so $D \not\isin M$.
172 Thus by \commitmergename, $D \isin C$. And $D \le Y$ so $D \le C$.
173 OK for $C \zhaspatch \p$.
175 So, in all cases, $C \zhaspatch \p$.
176 And by $L \haspatch \p$, $\exists_{F \in \py} F \le L$
177 and this $F \le C$ so indeed $C \haspatch \p$.
179 \subsubsection{For (wlog) $X \not\haspatch \p, Y \haspatch \p$:}
181 One of the Merge Ends conditions applies.
182 Recall that we are considering $D \in \py$.
183 $D \isin Y \equiv D \le Y$. $D \not\isin X$.
184 We will show for each of
186 if $M \haspatch \p$, $D \not\isin C$,
187 whereas if $M \nothaspatch \p$, $D \isin C \equiv D \le C$.
188 And by $Y \haspatch \p$, $\exists_{F \in \py} F \le Y$ and this
189 $F \le C$ so this suffices.
191 Consider $D = C$: Thus $C \in \py, L \in \py$.
192 By Tip Own Contents, $L \haspatch \p$ so $L \neq X$,
193 therefore we must have $L=Y$, $R=X$.
194 Conversely $R \not\in \py$
195 so by Tip Merge $M = \baseof{L}$. Thus $M \in \pn$ so
196 by Base Acyclic $M \nothaspatch \p$. By \commitmergename, $D \isin C$,
199 Consider $D \neq C, M \nothaspatch \p, D \isin Y$:
200 $D \le Y$ so $D \le C$.
201 $D \not\isin M$ so by \commitmergename, $D \isin C$. OK.
203 Consider $D \neq C, M \nothaspatch \p, D \not\isin Y$:
204 $D \not\le Y$. If $D \le X$ then
205 $D \in \pancsof{X}{\py}$, so by Addition Merge Ends and
206 Transitive Ancestors $D \le Y$ --- a contradiction, so $D \not\le X$.
207 Thus $D \not\le C$. By \commitmergename, $D \not\isin C$. OK.
209 Consider $D \neq C, M \haspatch \p, D \isin Y$:
210 $D \le Y$ so $D \in \pancsof{Y}{\py}$ so by Removal Merge Ends
211 and Transitive Ancestors $D \in \pancsof{M}{\py}$ so $D \le M$.
212 Thus $D \isin M$. By \commitmergename, $D \not\isin C$. OK.
214 Consider $D \neq C, M \haspatch \p, D \not\isin Y$:
215 By \commitmergename, $D \not\isin C$. OK.
219 \subsection{Base Acyclic}
221 This applies when $C \in \pn$.
222 $C \in \pn$ when $L \in \pn$ so by Merge Acyclic, $R \nothaspatch \p$.
224 Consider some $D \in \py$.
226 By Base Acyclic of $L$, $D \not\isin L$. By the above, $D \not\isin
227 R$. And $D \neq C$. So $D \not\isin C$.
231 \subsection{Tip Contents}
233 We need worry only about $C \in \py$.
234 And $\patchof{C} = \patchof{L}$
235 so $L \in \py$ so $L \haspatch \p$. We will use the Unique Base
236 of $C$, and its Coherence and Patch Inclusion, as just proved.
238 Firstly we show $C \haspatch \p$: If $R \in \py$, then $R \haspatch
239 \p$ and by Coherence/Inclusion $C \haspatch \p$ . If $R \not\in \py$
240 then by Tip Merge $M = \baseof{L}$ so by Base Acyclic and definition
241 of $\nothaspatch$, $M \nothaspatch \p$. So by Coherence/Inclusion $C
242 \haspatch \p$ (whether $R \haspatch \p$ or $\nothaspatch$).
244 We will consider an arbitrary commit $D$
245 and prove the Exclusive Tip Contents form.
247 \subsubsection{For $D \in \py$:}
248 $C \haspatch \p$ so by definition of $\haspatch$, $D \isin C \equiv D
251 \subsubsection{For $D \not\in \py, R \not\in \py$:}
253 $D \neq C$. By Tip Contents of $L$,
254 $D \isin L \equiv D \isin \baseof{L}$, so by Tip Merge condition,
255 $D \isin L \equiv D \isin M$. So by \commitmergename, $D \isin
256 C \equiv D \isin R$. And $R = \baseof{C}$ by Unique Base of $C$.
257 Thus $D \isin C \equiv D \isin \baseof{C}$. OK.
259 \subsubsection{For $D \not\in \py, R \in \py$:}
264 $D \isin L \equiv D \isin \baseof{L}$ and
265 $D \isin R \equiv D \isin \baseof{R}$.
267 Apply Tip Merge condition.
268 If $\baseof{L} = M$, trivially $D \isin M \equiv D \isin \baseof{L}.$
269 Whereas if $\baseof{L} = \baseof{M}$, by definition of $\base$,
270 $\patchof{M} = \patchof{L} = \py$, so by Tip Contents of $M$,
271 $D \isin M \equiv D \isin \baseof{M} \equiv D \isin \baseof{L}$.
273 So $D \isin M \equiv D \isin L$ so by \commitmergename,
274 $D \isin C \equiv D \isin R$. But from Unique Base,
275 $\baseof{C} = \baseof{R}$.
276 Therefore $D \isin C \equiv D \isin \baseof{C}$. OK.
280 \subsection{Unique Tips}
282 For $L \in \py$, trivially $\pendsof{C}{\py} = C$ so $T = C$ is
285 For $L \not\in \py$, $\pancsof{C}{\py} = \pancsof{L}{\py} \cup
286 \pancsof{R}{\py}$. So $T$ from Suitable Tips is a suitable $T$ for
291 \subsection{Foreign Inclusion}
293 Consider some $D \in \foreign$.
294 By Foreign Inclusion of $L, M, R$:
295 $D \isin L \equiv D \le L$;
296 $D \isin M \equiv D \le M$;
297 $D \isin R \equiv D \le R$.
299 \subsubsection{For $D = C$:}
301 $D \isin C$ and $D \le C$. OK.
303 \subsubsection{For $D \neq C, D \isin M$:}
305 Thus $D \le M$ so $D \le L$ and $D \le R$ so $D \isin L$ and $D \isin
306 R$. So by \commitmergename, $D \isin C$. And $D \le C$. OK.
308 \subsubsection{For $D \neq C, D \not\isin M, D \isin X$:}
310 By \commitmergename, $D \isin C$.
311 And $D \isin X$ means $D \le X$ so $D \le C$.
314 \subsubsection{For $D \neq C, D \not\isin M, D \not\isin L, D \not\isin R$:}
316 By \commitmergename, $D \not\isin C$.
317 And $D \not\le L, D \not\le R$ so $D \not\le C$.
322 \subsection{Foreign Contents}
324 Only relevant if $\isforeign{L}$, in which case
325 $\isforeign{C}$ and by Foreign Merges $\isforeign{R}$,
326 so Totally Foreign Contents applies. $\qed$
328 \subsection{Bases' Children}
330 If $L \in \py, R \in \py$: not applicable for either $D=L$ or $D=R$.
332 If $L \in \py, R \in \pn$: not applicable for $L$, OK for $R$.
334 Other possibilities for $L \in \py$ are excluded by Tip Merge.
336 If $L \in \pn, R \in \pn$: satisfied for both $L$ and $R$.
338 If $L \in \pn, R \in \foreign$: satisfied for $L$, not applicable for
341 If $L \in \pn, R \in \pqy$: satisfied for $L$, not applicable for
344 Other possibilities for $L \in \pn$ are excluded by Base Merge.
346 If $L \in \foreign$: not applicable for $L$; nor for $R$, by Foreign Merges.