3 Merge commits $L$ and $R$ using merge base $M$:
5 C \hasparents \{ L, R \}
7 \patchof{C} = \patchof{L}
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
14 $L \in \pn$, $R \in \pry$, $M = \baseof{R}$.
16 \subsection{Conditions}
17 \[ \eqn{ Ingredients }{
23 R \in \py : & \baseof{R} \ge \baseof{L}
24 \land [\baseof{L} = M \lor \baseof{L} = \baseof{M}] \\
25 R \in \pn : & M = \baseof{L} \\
26 \text{otherwise} : & \false
29 \[ \eqn{ Merge Acyclic }{
34 \[ \eqn{ Removal Merge Ends }{
35 X \not\haspatch \p \land
39 \pendsof{Y}{\py} = \pendsof{M}{\py}
41 \[ \eqn{ Addition Merge Ends }{
42 X \not\haspatch \p \land
43 M \nothaspatch \p \land
46 \bigforall_{E \in \pendsof{X}{\py}} E \le Y
49 \[ \eqn{ Foreign Merges }{
50 \patchof{L} = \bot \equiv \patchof{R} = \bot
53 \subsection{Non-Topbloke merges}
55 We require both $\patchof{L} = \bot$ and $\patchof{R} = \bot$
56 (Foreign Merges, above).
57 I.e. not only is it forbidden to merge into a Topbloke-controlled
58 branch without Topbloke's assistance, it is also forbidden to
59 merge any Topbloke-controlled branch into any plain git branch.
61 Given those conditions, Tip Merge and Merge Acyclic do not apply.
62 And $Y \not\in \py$ so $\neg [ Y \haspatch \p ]$ so neither
63 Merge Ends condition applies.
65 So a plain git merge of non-Topbloke branches meets the conditions and
66 is therefore consistent with our model.
68 \subsection{No Replay}
70 By definition of $\merge$,
71 $D \isin C \implies D \isin L \lor D \isin R \lor D = C$.
73 Ingredients Prevent Replay applies. $\qed$
75 \subsection{Unique Base}
77 Need to consider only $C \in \py$, ie $L \in \py$,
78 and calculate $\pendsof{C}{\pn}$. So we will consider some
79 putative ancestor $A \in \pn$ and see whether $A \le C$.
81 By Exact Ancestors for C, $A \le C \equiv A \le L \lor A \le R \lor A = C$.
82 But $C \in py$ and $A \in \pn$ so $A \neq C$.
83 Thus $A \le C \equiv A \le L \lor A \le R$.
85 By Unique Base of L and Transitive Ancestors,
86 $A \le L \equiv A \le \baseof{L}$.
88 \subsubsection{For $R \in \py$:}
90 By Unique Base of $R$ and Transitive Ancestors,
91 $A \le R \equiv A \le \baseof{R}$.
93 But by Tip Merge condition on $\baseof{R}$,
94 $A \le \baseof{L} \implies A \le \baseof{R}$, so
95 $A \le \baseof{R} \lor A \le \baseof{L} \equiv A \le \baseof{R}$.
96 Thus $A \le C \equiv A \le \baseof{R}$.
97 That is, $\baseof{C} = \baseof{R}$.
99 \subsubsection{For $R \in \pn$:}
101 By Tip Merge condition on $R$ and since $M \le R$,
102 $A \le \baseof{L} \implies A \le R$, so
103 $A \le R \lor A \le \baseof{L} \equiv A \le R$.
104 Thus $A \le C \equiv A \le R$.
105 That is, $\baseof{C} = R$.
109 \subsection{Coherence and Patch Inclusion}
111 Need to determine $C \haspatch \p$ based on $L,M,R \haspatch \p$.
112 This involves considering $D \in \py$.
114 \subsubsection{For $L \nothaspatch \p, R \nothaspatch \p$:}
115 $D \not\isin L \land D \not\isin R$. $C \not\in \py$ (otherwise $L
116 \in \py$ ie $L \haspatch \p$ by Tip Self Inpatch for $L$). So $D \neq C$.
117 Applying $\merge$ gives $D \not\isin C$ i.e. $C \nothaspatch \p$.
119 \subsubsection{For $L \haspatch \p, R \haspatch \p$:}
120 $D \isin L \equiv D \le L$ and $D \isin R \equiv D \le R$.
121 (Likewise $D \isin X \equiv D \le X$ and $D \isin Y \equiv D \le Y$.)
123 Consider $D = C$: $D \isin C$, $D \le C$, OK for $C \haspatch \p$.
125 For $D \neq C$: $D \le C \equiv D \le L \lor D \le R
126 \equiv D \isin L \lor D \isin R$.
127 (Likewise $D \le C \equiv D \le X \lor D \le Y$.)
129 Consider $D \neq C, D \isin X \land D \isin Y$:
130 By $\merge$, $D \isin C$. Also $D \le X$
131 so $D \le C$. OK for $C \haspatch \p$.
133 Consider $D \neq C, D \not\isin X \land D \not\isin Y$:
134 By $\merge$, $D \not\isin C$.
135 And $D \not\le X \land D \not\le Y$ so $D \not\le C$.
136 OK for $C \haspatch \p$.
138 Remaining case, wlog, is $D \not\isin X \land D \isin Y$.
139 $D \not\le X$ so $D \not\le M$ so $D \not\isin M$.
140 Thus by $\merge$, $D \isin C$. And $D \le Y$ so $D \le C$.
141 OK for $C \haspatch \p$.
143 So indeed $L \haspatch \p \land R \haspatch \p \implies C \haspatch \p$.
145 \subsubsection{For (wlog) $X \not\haspatch \p, Y \haspatch \p$:}
147 $M \haspatch \p \implies C \nothaspatch \p$.
148 $M \nothaspatch \p \implies C \haspatch \p$.
152 One of the Merge Ends conditions applies.
153 Recall that we are considering $D \in \py$.
154 $D \isin Y \equiv D \le Y$. $D \not\isin X$.
155 We will show for each of
156 various cases that $D \isin C \equiv M \nothaspatch \p \land D \le C$
157 (which suffices by definition of $\haspatch$ and $\nothaspatch$).
159 Consider $D = C$: Thus $C \in \py, L \in \py$, and by Tip
160 Self Inpatch for $L$, $L \haspatch \p$, so $L=Y, R=X$. By Tip Merge,
161 $M=\baseof{L}$. So by Base Acyclic $D \not\isin M$, i.e.
162 $M \nothaspatch \p$. And indeed $D \isin C$ and $D \le C$. OK.
164 Consider $D \neq C, M \nothaspatch P, D \isin Y$:
165 $D \le Y$ so $D \le C$.
166 $D \not\isin M$ so by $\merge$, $D \isin C$. OK.
168 Consider $D \neq C, M \nothaspatch P, D \not\isin Y$:
169 $D \not\le Y$. If $D \le X$ then
170 $D \in \pancsof{X}{\py}$, so by Addition Merge Ends and
171 Transitive Ancestors $D \le Y$ --- a contradiction, so $D \not\le X$.
172 Thus $D \not\le C$. By $\merge$, $D \not\isin C$. OK.
174 Consider $D \neq C, M \haspatch P, D \isin Y$:
175 $D \le Y$ so $D \in \pancsof{Y}{\py}$ so by Removal Merge Ends
176 and Transitive Ancestors $D \in \pancsof{M}{\py}$ so $D \le M$.
177 Thus $D \isin M$. By $\merge$, $D \not\isin C$. OK.
179 Consider $D \neq C, M \haspatch P, D \not\isin Y$:
180 By $\merge$, $D \not\isin C$. OK.
184 \subsection{Base Acyclic}
186 This applies when $C \in \pn$.
187 $C \in \pn$ when $L \in \pn$ so by Merge Acyclic, $R \nothaspatch \p$.
189 Consider some $D \in \py$.
191 By Base Acyclic of $L$, $D \not\isin L$. By the above, $D \not\isin
192 R$. And $D \neq C$. So $D \not\isin C$.
196 \subsection{Tip Contents}
198 We need worry only about $C \in \py$.
199 And $\patchof{C} = \patchof{L}$
200 so $L \in \py$ so $L \haspatch \p$. We will use the Unique Base
201 of $C$, and its Coherence and Patch Inclusion, as just proved.
203 Firstly we show $C \haspatch \p$: If $R \in \py$, then $R \haspatch
204 \p$ and by Coherence/Inclusion $C \haspatch \p$ . If $R \not\in \py$
205 then by Tip Merge $M = \baseof{L}$ so by Base Acyclic and definition
206 of $\nothaspatch$, $M \nothaspatch \p$. So by Coherence/Inclusion $C
207 \haspatch \p$ (whether $R \haspatch \p$ or $\nothaspatch$).
209 We will consider an arbitrary commit $D$
210 and prove the Exclusive Tip Contents form.
212 \subsubsection{For $D \in \py$:}
213 $C \haspatch \p$ so by definition of $\haspatch$, $D \isin C \equiv D
216 \subsubsection{For $D \not\in \py, R \not\in \py$:}
218 $D \neq C$. By Tip Contents of $L$,
219 $D \isin L \equiv D \isin \baseof{L}$, and by Tip Merge condition,
220 $D \isin L \equiv D \isin M$. So by definition of $\merge$, $D \isin
221 C \equiv D \isin R$. And $R = \baseof{C}$ by Unique Base of $C$.
222 Thus $D \isin C \equiv D \isin \baseof{C}$. OK.
224 \subsubsection{For $D \not\in \py, R \in \py$:}
229 $D \isin L \equiv D \isin \baseof{L}$ and
230 $D \isin R \equiv D \isin \baseof{R}$.
232 If $\baseof{L} = M$, trivially $D \isin M \equiv D \isin \baseof{L}.$
233 Whereas if $\baseof{L} = \baseof{M}$, by definition of $\base$,
234 $\patchof{M} = \patchof{L} = \py$, so by Tip Contents of $M$,
235 $D \isin M \equiv D \isin \baseof{M} \equiv D \isin \baseof{L}$.
237 So $D \isin M \equiv D \isin L$ and by $\merge$,
238 $D \isin C \equiv D \isin R$. But from Unique Base,
239 $\baseof{C} = R$ so $D \isin C \equiv D \isin \baseof{C}$. OK.
243 \subsection{Foreign Inclusion}
245 Consider some $D$ s.t. $\patchof{D} = \bot$.
246 By Foreign Inclusion of $L, M, R$:
247 $D \isin L \equiv D \le L$;
248 $D \isin M \equiv D \le M$;
249 $D \isin R \equiv D \le R$.
251 \subsubsection{For $D = C$:}
253 $D \isin C$ and $D \le C$. OK.
255 \subsubsection{For $D \neq C, D \isin M$:}
257 Thus $D \le M$ so $D \le L$ and $D \le R$ so $D \isin L$ and $D \isin
258 R$. So by $\merge$, $D \isin C$. And $D \le C$. OK.
260 \subsubsection{For $D \neq C, D \not\isin M, D \isin X$:}
262 By $\merge$, $D \isin C$.
263 And $D \isin X$ means $D \le X$ so $D \le C$.
266 \subsubsection{For $D \neq C, D \not\isin M, D \not\isin L, D \not\isin R$:}
268 By $\merge$, $D \not\isin C$.
269 And $D \not\le L, D \not\le R$ so $D \not\le C$.
274 \subsection{Foreign Contents}
276 Only relevant if $\patchof{L} = \bot$, in which case
277 $\patchof{C} = \bot$ and by Foreign Merges $\patchof{R} = \bot$,
278 so Totally Foreign Contents applies. $\qed$