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{ Merge Acyclic }{
35 \[ \eqn{ Removal Merge Ends }{
36 X \not\haspatch \p \land
40 \pendsof{Y}{\py} = \pendsof{M}{\py}
42 \[ \eqn{ Addition Merge Ends }{
43 X \not\haspatch \p \land
44 M \nothaspatch \p \land
47 \bigforall_{E \in \pendsof{X}{\py}} E \le Y
50 \[ \eqn{ Suitable Tips }{
51 \bigforall_{\p \neq \patchof{L}, \; C \haspatch \p}
53 \pendsof{J}{\py} = \{ T \}
55 \forall_{E \in \pendsof{K}{\py}} T \ge E
56 , \text{where} \{J,K\} = \{L,R\}
58 \[ \eqn{ Foreign Merges }{
59 \isforeign{L} \implies \isforeign{R}
62 \subsection{Non-Topbloke merges}
64 We require both $\isforeign{L}$ and $\isforeign{R}$
65 (Foreign Merges, above).
66 I.e. not only is it forbidden to merge into a Topbloke-controlled
67 branch without Topbloke's assistance, it is also forbidden to
68 merge any Topbloke-controlled branch into any plain git branch.
70 Given those conditions, Tip Merge and Merge Acyclic do not apply.
71 By Foreign Contents of $L$, $\isforeign{M}$ as well.
72 So by Foreign Contents for any $A \in \{L,M,R\}$,
73 $\forall_{\p, D \in \py} D \not\le A$
74 so $\pendsof{A}{\py} = \{ \}$ and the RHS of both Merge Ends
75 conditions are satisifed.
77 So a plain git merge of non-Topbloke branches meets the conditions and
78 is therefore consistent with our model.
80 \subsection{No Replay}
82 By definition of $\commitmerge$,
83 $D \isin C \implies D \isin L \lor D \isin R \lor D = C$.
85 Ingredients Prevent Replay applies. $\qed$
87 \subsection{Unique Base}
89 Need to consider only $C \in \py$, ie $L \in \py$,
90 and calculate $\pendsof{C}{\pn}$. So we will consider some
91 putative ancestor $A \in \pn$ and see whether $A \le C$.
93 By Exact Ancestors for C, $A \le C \equiv A \le L \lor A \le R \lor A = C$.
94 But $C \in \py$ and $A \in \pn$ so $A \neq C$.
95 Thus $A \le C \equiv A \le L \lor A \le R$.
97 By Unique Base of L and Transitive Ancestors,
98 $A \le L \equiv A \le \baseof{L}$.
100 \subsubsection{For $R \in \py$:}
102 By Unique Base of $R$ and Transitive Ancestors,
103 $A \le R \equiv A \le \baseof{R}$.
105 But by Tip Merge condition on $\baseof{R}$,
106 $A \le \baseof{L} \implies A \le \baseof{R}$, so
107 $A \le \baseof{R} \lor A \le \baseof{L} \equiv A \le \baseof{R}$.
108 Thus $A \le C \equiv A \le \baseof{R}$.
109 That is, $\baseof{C} = \baseof{R}$.
111 \subsubsection{For $R \in \pn$:}
113 By Tip Merge condition and since $M \le R$,
114 $A \le \baseof{L} \implies A \le R$, so
115 $A \le R \lor A \le \baseof{L} \equiv A \le R$.
116 Thus $A \le C \equiv A \le R$.
117 That is, $\baseof{C} = R$.
121 \subsection{Coherence and Patch Inclusion}
125 L \nothaspatch \p \land R \nothaspatch \p : & C \nothaspatch \p \\
126 L \haspatch \p \land R \haspatch \p : & C \haspatch \p \\
127 \text{otherwise} \land M \haspatch \p : & C \nothaspatch \p \\
128 \text{otherwise} \land M \nothaspatch \p : & C \haspatch \p
132 ~ Consider $D \in \py$.
134 \subsubsection{For $L \nothaspatch \p, R \nothaspatch \p$:}
135 $D \not\isin L \land D \not\isin R$. $C \not\in \py$ (otherwise $L
136 \in \py$ ie $L \haspatch \p$ by Tip Own Contents for $L$).
138 Applying $\commitmerge$ gives $D \not\isin C$ i.e. $C \nothaspatch \p$.
141 \subsubsection{For $L \haspatch \p, R \haspatch \p$:}
142 $D \isin L \equiv D \le L$ and $D \isin R \equiv D \le R$.
143 (Likewise $D \isin X \equiv D \le X$ and $D \isin Y \equiv D \le Y$.)
145 Consider $D = C$: $D \isin C$, $D \le C$, OK for $C \zhaspatch \p$.
147 For $D \neq C$: $D \le C \equiv D \le L \lor D \le R
148 \equiv D \isin L \lor D \isin R$.
149 (Likewise $D \le C \equiv D \le X \lor D \le Y$.)
151 Consider $D \neq C, D \isin X \land D \isin Y$:
152 By $\commitmerge$, $D \isin C$. Also $D \le X$
153 so $D \le C$. OK for $C \zhaspatch \p$.
155 Consider $D \neq C, D \not\isin X \land D \not\isin Y$:
156 By $\commitmerge$, $D \not\isin C$.
157 And $D \not\le X \land D \not\le Y$ so $D \not\le C$.
158 OK for $C \zhaspatch \p$.
160 Remaining case, wlog, is $D \not\isin X \land D \isin Y$.
161 $D \not\le X$ so $D \not\le M$ so $D \not\isin M$.
162 Thus by $\commitmerge$, $D \isin C$. And $D \le Y$ so $D \le C$.
163 OK for $C \zhaspatch \p$.
165 So, in all cases, $C \zhaspatch \p$.
166 And by $L \haspatch \p$, $\exists_{F \in \py} F \le L$
167 and this $F \le C$ so indeed $C \haspatch \p$.
169 \subsubsection{For (wlog) $X \not\haspatch \p, Y \haspatch \p$:}
171 One of the Merge Ends conditions applies.
172 Recall that we are considering $D \in \py$.
173 $D \isin Y \equiv D \le Y$. $D \not\isin X$.
174 We will show for each of
176 if $M \haspatch \p$, $D \not\isin C$,
177 whereas if $M \nothaspatch \p$, $D \isin C \equiv D \le C$.
178 And by $Y \haspatch \p$, $\exists_{F \in \py} F \le Y$ and this
179 $F \le C$ so this suffices.
181 Consider $D = C$: Thus $C \in \py, L \in \py$.
182 By Tip Own Contents, $L \haspatch \p$ so $L \neq X$,
183 therefore we must have $L=Y$, $R=X$.
184 Conversely $R \not\in \py$
185 so by Tip Merge $M = \baseof{L}$. Thus $M \in \pn$ so
186 by Base Acyclic $M \nothaspatch \p$. By $\commitmerge$, $D \isin C$,
189 Consider $D \neq C, M \nothaspatch \p, D \isin Y$:
190 $D \le Y$ so $D \le C$.
191 $D \not\isin M$ so by $\commitmerge$, $D \isin C$. OK.
193 Consider $D \neq C, M \nothaspatch \p, D \not\isin Y$:
194 $D \not\le Y$. If $D \le X$ then
195 $D \in \pancsof{X}{\py}$, so by Addition Merge Ends and
196 Transitive Ancestors $D \le Y$ --- a contradiction, so $D \not\le X$.
197 Thus $D \not\le C$. By $\commitmerge$, $D \not\isin C$. OK.
199 Consider $D \neq C, M \haspatch \p, D \isin Y$:
200 $D \le Y$ so $D \in \pancsof{Y}{\py}$ so by Removal Merge Ends
201 and Transitive Ancestors $D \in \pancsof{M}{\py}$ so $D \le M$.
202 Thus $D \isin M$. By $\commitmerge$, $D \not\isin C$. OK.
204 Consider $D \neq C, M \haspatch \p, D \not\isin Y$:
205 By $\commitmerge$, $D \not\isin C$. OK.
209 \subsection{Base Acyclic}
211 This applies when $C \in \pn$.
212 $C \in \pn$ when $L \in \pn$ so by Merge Acyclic, $R \nothaspatch \p$.
214 Consider some $D \in \py$.
216 By Base Acyclic of $L$, $D \not\isin L$. By the above, $D \not\isin
217 R$. And $D \neq C$. So $D \not\isin C$.
221 \subsection{Tip Contents}
223 We need worry only about $C \in \py$.
224 And $\patchof{C} = \patchof{L}$
225 so $L \in \py$ so $L \haspatch \p$. We will use the Unique Base
226 of $C$, and its Coherence and Patch Inclusion, as just proved.
228 Firstly we show $C \haspatch \p$: If $R \in \py$, then $R \haspatch
229 \p$ and by Coherence/Inclusion $C \haspatch \p$ . If $R \not\in \py$
230 then by Tip Merge $M = \baseof{L}$ so by Base Acyclic and definition
231 of $\nothaspatch$, $M \nothaspatch \p$. So by Coherence/Inclusion $C
232 \haspatch \p$ (whether $R \haspatch \p$ or $\nothaspatch$).
234 We will consider an arbitrary commit $D$
235 and prove the Exclusive Tip Contents form.
237 \subsubsection{For $D \in \py$:}
238 $C \haspatch \p$ so by definition of $\haspatch$, $D \isin C \equiv D
241 \subsubsection{For $D \not\in \py, R \not\in \py$:}
243 $D \neq C$. By Tip Contents of $L$,
244 $D \isin L \equiv D \isin \baseof{L}$, so by Tip Merge condition,
245 $D \isin L \equiv D \isin M$. So by $\commitmerge$, $D \isin
246 C \equiv D \isin R$. And $R = \baseof{C}$ by Unique Base of $C$.
247 Thus $D \isin C \equiv D \isin \baseof{C}$. OK.
249 \subsubsection{For $D \not\in \py, R \in \py$:}
254 $D \isin L \equiv D \isin \baseof{L}$ and
255 $D \isin R \equiv D \isin \baseof{R}$.
257 Apply Tip Merge condition.
258 If $\baseof{L} = M$, trivially $D \isin M \equiv D \isin \baseof{L}.$
259 Whereas if $\baseof{L} = \baseof{M}$, by definition of $\base$,
260 $\patchof{M} = \patchof{L} = \py$, so by Tip Contents of $M$,
261 $D \isin M \equiv D \isin \baseof{M} \equiv D \isin \baseof{L}$.
263 So $D \isin M \equiv D \isin L$ so by $\commitmerge$,
264 $D \isin C \equiv D \isin R$. But from Unique Base,
265 $\baseof{C} = \baseof{R}$.
266 Therefore $D \isin C \equiv D \isin \baseof{C}$. OK.
270 \subsection{Unique Tips}
272 For $L \in \py$, trivially $\pendsof{C}{\py} = C$ so $T = C$ is
275 For $L \not\in \py$, $\pancsof{C}{\py} = \pancsof{L}{\py} \cup
276 \pancsof{R}{\py}$. So $T$ from Suitable Tips is a suitable $T$ for
281 \subsection{Foreign Inclusion}
283 Consider some $D \in \foreign$.
284 By Foreign Inclusion of $L, M, R$:
285 $D \isin L \equiv D \le L$;
286 $D \isin M \equiv D \le M$;
287 $D \isin R \equiv D \le R$.
289 \subsubsection{For $D = C$:}
291 $D \isin C$ and $D \le C$. OK.
293 \subsubsection{For $D \neq C, D \isin M$:}
295 Thus $D \le M$ so $D \le L$ and $D \le R$ so $D \isin L$ and $D \isin
296 R$. So by $\commitmerge$, $D \isin C$. And $D \le C$. OK.
298 \subsubsection{For $D \neq C, D \not\isin M, D \isin X$:}
300 By $\commitmerge$, $D \isin C$.
301 And $D \isin X$ means $D \le X$ so $D \le C$.
304 \subsubsection{For $D \neq C, D \not\isin M, D \not\isin L, D \not\isin R$:}
306 By $\commitmerge$, $D \not\isin C$.
307 And $D \not\le L, D \not\le R$ so $D \not\le C$.
312 \subsection{Foreign Contents}
314 Only relevant if $\isforeign{L}$, in which case
315 $\isforeign{C}$ and by Foreign Merges $\isforeign{R}$,
316 so Totally Foreign Contents applies. $\qed$