Autogenerated HTML docs for v2.48.0-rc0-135-g996f0
[git-htmldocs.git] / git-bisect-lk2009.html
blob9474c27637dfc9c434da2cd2c1b606baf6c159fc
1 <!DOCTYPE html>
2 <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
3 <head>
4 <meta charset="UTF-8"/>
5 <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
6 <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
7 <meta name="generator" content="Asciidoctor 2.0.20"/>
8 <meta name="author" content="Christian Couder"/>
9 <title>Fighting regressions with git bisect</title>
10 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"/>
11 <style>
12 /*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
13 /* Uncomment the following line when using as a custom stylesheet */
14 /* @import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"; */
15 html{font-family:sans-serif;-webkit-text-size-adjust:100%}
16 a{background:none}
17 a:focus{outline:thin dotted}
18 a:active,a:hover{outline:0}
19 h1{font-size:2em;margin:.67em 0}
20 b,strong{font-weight:bold}
21 abbr{font-size:.9em}
22 abbr[title]{cursor:help;border-bottom:1px dotted #dddddf;text-decoration:none}
23 dfn{font-style:italic}
24 hr{height:0}
25 mark{background:#ff0;color:#000}
26 code,kbd,pre,samp{font-family:monospace;font-size:1em}
27 pre{white-space:pre-wrap}
28 q{quotes:"\201C" "\201D" "\2018" "\2019"}
29 small{font-size:80%}
30 sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
31 sup{top:-.5em}
32 sub{bottom:-.25em}
33 img{border:0}
34 svg:not(:root){overflow:hidden}
35 figure{margin:0}
36 audio,video{display:inline-block}
37 audio:not([controls]){display:none;height:0}
38 fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
39 legend{border:0;padding:0}
40 button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
41 button,input{line-height:normal}
42 button,select{text-transform:none}
43 button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}
44 button[disabled],html input[disabled]{cursor:default}
45 input[type=checkbox],input[type=radio]{padding:0}
46 button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
47 textarea{overflow:auto;vertical-align:top}
48 table{border-collapse:collapse;border-spacing:0}
49 *,::before,::after{box-sizing:border-box}
50 html,body{font-size:100%}
51 body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;line-height:1;position:relative;cursor:auto;-moz-tab-size:4;-o-tab-size:4;tab-size:4;word-wrap:anywhere;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
52 a:hover{cursor:pointer}
53 img,object,embed{max-width:100%;height:auto}
54 object,embed{height:100%}
55 img{-ms-interpolation-mode:bicubic}
56 .left{float:left!important}
57 .right{float:right!important}
58 .text-left{text-align:left!important}
59 .text-right{text-align:right!important}
60 .text-center{text-align:center!important}
61 .text-justify{text-align:justify!important}
62 .hide{display:none}
63 img,object,svg{display:inline-block;vertical-align:middle}
64 textarea{height:auto;min-height:50px}
65 select{width:100%}
66 .subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
67 div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0}
68 a{color:#2156a5;text-decoration:underline;line-height:inherit}
69 a:hover,a:focus{color:#1d4b8f}
70 a img{border:0}
71 p{line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
72 p aside{font-size:.875em;line-height:1.35;font-style:italic}
73 h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
74 h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
75 h1{font-size:2.125em}
76 h2{font-size:1.6875em}
77 h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
78 h4,h5{font-size:1.125em}
79 h6{font-size:1em}
80 hr{border:solid #dddddf;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em}
81 em,i{font-style:italic;line-height:inherit}
82 strong,b{font-weight:bold;line-height:inherit}
83 small{font-size:60%;line-height:inherit}
84 code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
85 ul,ol,dl{line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
86 ul,ol{margin-left:1.5em}
87 ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0}
88 ul.circle{list-style-type:circle}
89 ul.disc{list-style-type:disc}
90 ul.square{list-style-type:square}
91 ul.circle ul:not([class]),ul.disc ul:not([class]),ul.square ul:not([class]){list-style:inherit}
92 ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
93 dl dt{margin-bottom:.3125em;font-weight:bold}
94 dl dd{margin-bottom:1.25em}
95 blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
96 blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
97 @media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
98 h1{font-size:2.75em}
99 h2{font-size:2.3125em}
100 h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
101 h4{font-size:1.4375em}}
102 table{background:#fff;margin-bottom:1.25em;border:1px solid #dedede;word-wrap:normal}
103 table thead,table tfoot{background:#f7f8f7}
104 table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
105 table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
106 table tr.even,table tr.alt{background:#f8f8f7}
107 table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{line-height:1.6}
108 h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
109 h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
110 .center{margin-left:auto;margin-right:auto}
111 .stretch{width:100%}
112 .clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
113 .clearfix::after,.float-group::after{clear:both}
114 :not(pre).nobreak{word-wrap:normal}
115 :not(pre).nowrap{white-space:nowrap}
116 :not(pre).pre-wrap{white-space:pre-wrap}
117 :not(pre):not([class^=L])>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background:#f7f7f8;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
118 pre{color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;line-height:1.45;text-rendering:optimizeSpeed}
119 pre code,pre pre{color:inherit;font-size:inherit;line-height:inherit}
120 pre>code{display:block}
121 pre.nowrap,pre.nowrap pre{white-space:pre;word-wrap:normal}
122 em em{font-style:normal}
123 strong strong{font-weight:400}
124 .keyseq{color:rgba(51,51,51,.8)}
125 kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background:#f7f7f7;border:1px solid #ccc;border-radius:3px;box-shadow:0 1px 0 rgba(0,0,0,.2),inset 0 0 0 .1em #fff;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
126 .keyseq kbd:first-child{margin-left:0}
127 .keyseq kbd:last-child{margin-right:0}
128 .menuseq,.menuref{color:#000}
129 .menuseq b:not(.caret),.menuref{font-weight:inherit}
130 .menuseq{word-spacing:-.02em}
131 .menuseq b.caret{font-size:1.25em;line-height:.8}
132 .menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
133 b.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
134 b.button::before{content:"[";padding:0 3px 0 2px}
135 b.button::after{content:"]";padding:0 2px 0 3px}
136 p a>code:hover{color:rgba(0,0,0,.9)}
137 #header,#content,#footnotes,#footer{width:100%;margin:0 auto;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
138 #header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
139 #header::after,#content::after,#footnotes::after,#footer::after{clear:both}
140 #content{margin-top:1.25em}
141 #content::before{content:none}
142 #header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
143 #header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #dddddf}
144 #header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #dddddf;padding-bottom:8px}
145 #header .details{border-bottom:1px solid #dddddf;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:flex;flex-flow:row wrap}
146 #header .details span:first-child{margin-left:-.125em}
147 #header .details span.email a{color:rgba(0,0,0,.85)}
148 #header .details br{display:none}
149 #header .details br+span::before{content:"\00a0\2013\00a0"}
150 #header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
151 #header .details br+span#revremark::before{content:"\00a0|\00a0"}
152 #header #revnumber{text-transform:capitalize}
153 #header #revnumber::after{content:"\00a0"}
154 #content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #dddddf;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
155 #toc{border-bottom:1px solid #e7e7e9;padding-bottom:.5em}
156 #toc>ul{margin-left:.125em}
157 #toc ul.sectlevel0>li>a{font-style:italic}
158 #toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
159 #toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
160 #toc li{line-height:1.3334;margin-top:.3334em}
161 #toc a{text-decoration:none}
162 #toc a:active{text-decoration:underline}
163 #toctitle{color:#7a2518;font-size:1.2em}
164 @media screen and (min-width:768px){#toctitle{font-size:1.375em}
165 body.toc2{padding-left:15em;padding-right:0}
166 #toc.toc2{margin-top:0!important;background:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
167 #toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
168 #toc.toc2>ul{font-size:.9em;margin-bottom:0}
169 #toc.toc2 ul ul{margin-left:0;padding-left:1em}
170 #toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
171 body.toc2.toc-right{padding-left:0;padding-right:15em}
172 body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #e7e7e9;left:auto;right:0}}
173 @media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
174 #toc.toc2{width:20em}
175 #toc.toc2 #toctitle{font-size:1.375em}
176 #toc.toc2>ul{font-size:.95em}
177 #toc.toc2 ul ul{padding-left:1.25em}
178 body.toc2.toc-right{padding-left:0;padding-right:20em}}
179 #content #toc{border:1px solid #e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;border-radius:4px}
180 #content #toc>:first-child{margin-top:0}
181 #content #toc>:last-child{margin-bottom:0}
182 #footer{max-width:none;background:rgba(0,0,0,.8);padding:1.25em}
183 #footer-text{color:hsla(0,0%,100%,.8);line-height:1.44}
184 #content{margin-bottom:.625em}
185 .sect1{padding-bottom:.625em}
186 @media screen and (min-width:768px){#content{margin-bottom:1.25em}
187 .sect1{padding-bottom:1.25em}}
188 .sect1:last-child{padding-bottom:0}
189 .sect1+.sect1{border-top:1px solid #e7e7e9}
190 #content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
191 #content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
192 #content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
193 #content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
194 #content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
195 details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
196 details{margin-left:1.25rem}
197 details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;outline:none;-webkit-tap-highlight-color:transparent}
198 details>summary::-webkit-details-marker{display:none}
199 details>summary::before{content:"";border:solid transparent;border-left:solid;border-width:.3em 0 .3em .5em;position:absolute;top:.5em;left:-1.25rem;transform:translateX(15%)}
200 details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)}
201 details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem}
202 .admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
203 table.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
204 .paragraph.lead>p,#preamble>.sectionbody>[class=paragraph]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
205 .admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
206 .admonitionblock>table td.icon{text-align:center;width:80px}
207 .admonitionblock>table td.icon img{max-width:none}
208 .admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
209 .admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6);word-wrap:anywhere}
210 .admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
211 .exampleblock>.content{border:1px solid #e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;border-radius:4px}
212 .sidebarblock{border:1px solid #dbdbd6;margin-bottom:1.25em;padding:1.25em;background:#f3f3f2;border-radius:4px}
213 .sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
214 .exampleblock>.content>:first-child,.sidebarblock>.content>:first-child{margin-top:0}
215 .exampleblock>.content>:last-child,.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
216 .literalblock pre,.listingblock>.content>pre{border-radius:4px;overflow-x:auto;padding:1em;font-size:.8125em}
217 @media screen and (min-width:768px){.literalblock pre,.listingblock>.content>pre{font-size:.90625em}}
218 @media screen and (min-width:1280px){.literalblock pre,.listingblock>.content>pre{font-size:1em}}
219 .literalblock pre,.listingblock>.content>pre:not(.highlight),.listingblock>.content>pre[class=highlight],.listingblock>.content>pre[class^="highlight "]{background:#f7f7f8}
220 .literalblock.output pre{color:#f7f7f8;background:rgba(0,0,0,.9)}
221 .listingblock>.content{position:relative}
222 .listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:inherit;opacity:.5}
223 .listingblock:hover code[data-lang]::before{display:block}
224 .listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:inherit;opacity:.5}
225 .listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
226 .listingblock pre.highlightjs{padding:0}
227 .listingblock pre.highlightjs>code{padding:1em;border-radius:4px}
228 .listingblock pre.prettyprint{border-width:0}
229 .prettyprint{background:#f7f7f8}
230 pre.prettyprint .linenums{line-height:1.45;margin-left:2em}
231 pre.prettyprint li{background:none;list-style-type:inherit;padding-left:0}
232 pre.prettyprint li code[data-lang]::before{opacity:1}
233 pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
234 table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none}
235 table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal}
236 table.linenotable td.code{padding-left:.75em}
237 table.linenotable td.linenos,pre.pygments .linenos{border-right:1px solid;opacity:.35;padding-right:.5em;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
238 pre.pygments span.linenos{display:inline-block;margin-right:.75em}
239 .quoteblock{margin:0 1em 1.25em 1.5em;display:table}
240 .quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em}
241 .quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
242 .quoteblock blockquote{margin:0;padding:0;border:0}
243 .quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
244 .quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
245 .quoteblock .attribution{margin-top:.75em;margin-right:.5ex;text-align:right}
246 .verseblock{margin:0 1em 1.25em}
247 .verseblock pre{font-family:"Open Sans","DejaVu Sans",sans-serif;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
248 .verseblock pre strong{font-weight:400}
249 .verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
250 .quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
251 .quoteblock .attribution br,.verseblock .attribution br{display:none}
252 .quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
253 .quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
254 .quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:1.6;word-spacing:0}
255 .quoteblock.abstract{margin:0 1em 1.25em;display:block}
256 .quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
257 .quoteblock.excerpt>blockquote,.quoteblock .quoteblock{padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
258 .quoteblock.excerpt,.quoteblock .quoteblock{margin-left:0}
259 .quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
260 .quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;font-size:.85rem;text-align:left;margin-right:0}
261 p.tableblock:last-child{margin-bottom:0}
262 td.tableblock>.content{margin-bottom:1.25em;word-wrap:anywhere}
263 td.tableblock>.content>:last-child{margin-bottom:-1.25em}
264 table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
265 table.grid-all>*>tr>*{border-width:1px}
266 table.grid-cols>*>tr>*{border-width:0 1px}
267 table.grid-rows>*>tr>*{border-width:1px 0}
268 table.frame-all{border-width:1px}
269 table.frame-ends{border-width:1px 0}
270 table.frame-sides{border-width:0 1px}
271 table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-child>*{border-top-width:0}
272 table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}
273 table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0}
274 table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0}
275 table.stripes-all>*>tr,table.stripes-odd>*>tr:nth-of-type(odd),table.stripes-even>*>tr:nth-of-type(even),table.stripes-hover>*>tr:hover{background:#f8f8f7}
276 th.halign-left,td.halign-left{text-align:left}
277 th.halign-right,td.halign-right{text-align:right}
278 th.halign-center,td.halign-center{text-align:center}
279 th.valign-top,td.valign-top{vertical-align:top}
280 th.valign-bottom,td.valign-bottom{vertical-align:bottom}
281 th.valign-middle,td.valign-middle{vertical-align:middle}
282 table thead th,table tfoot th{font-weight:bold}
283 tbody tr th{background:#f7f8f7}
284 tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
285 p.tableblock>code:only-child{background:none;padding:0}
286 p.tableblock{font-size:1em}
287 ol{margin-left:1.75em}
288 ul li ol{margin-left:1.5em}
289 dl dd{margin-left:1.125em}
290 dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
291 li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
292 ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
293 ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
294 ul.unstyled,ol.unstyled{margin-left:0}
295 li>p:empty:only-child::before{content:"";display:inline-block}
296 ul.checklist>li>p:first-child{margin-left:-1em}
297 ul.checklist>li>p:first-child>.fa-square-o:first-child,ul.checklist>li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
298 ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em}
299 ul.inline{display:flex;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
300 ul.inline>li{margin-left:1.25em}
301 .unstyled dl dt{font-weight:400;font-style:normal}
302 ol.arabic{list-style-type:decimal}
303 ol.decimal{list-style-type:decimal-leading-zero}
304 ol.loweralpha{list-style-type:lower-alpha}
305 ol.upperalpha{list-style-type:upper-alpha}
306 ol.lowerroman{list-style-type:lower-roman}
307 ol.upperroman{list-style-type:upper-roman}
308 ol.lowergreek{list-style-type:lower-greek}
309 .hdlist>table,.colist>table{border:0;background:none}
310 .hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
311 td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
312 td.hdlist1{font-weight:bold;padding-bottom:1.25em}
313 td.hdlist2{word-wrap:anywhere}
314 .literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
315 .colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
316 .colist td:not([class]):first-child img{max-width:none}
317 .colist td:not([class]):last-child{padding:.25em 0}
318 .thumb,.th{line-height:0;display:inline-block;border:4px solid #fff;box-shadow:0 0 0 1px #ddd}
319 .imageblock.left{margin:.25em .625em 1.25em 0}
320 .imageblock.right{margin:.25em 0 1.25em .625em}
321 .imageblock>.title{margin-bottom:0}
322 .imageblock.thumb,.imageblock.th{border-width:6px}
323 .imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
324 .image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
325 .image.left{margin-right:.625em}
326 .image.right{margin-left:.625em}
327 a.image{text-decoration:none;display:inline-block}
328 a.image object{pointer-events:none}
329 sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
330 sup.footnote a,sup.footnoteref a{text-decoration:none}
331 sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
332 #footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
333 #footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
334 #footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
335 #footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
336 #footnotes .footnote:last-of-type{margin-bottom:0}
337 #content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
338 div.unbreakable{page-break-inside:avoid}
339 .big{font-size:larger}
340 .small{font-size:smaller}
341 .underline{text-decoration:underline}
342 .overline{text-decoration:overline}
343 .line-through{text-decoration:line-through}
344 .aqua{color:#00bfbf}
345 .aqua-background{background:#00fafa}
346 .black{color:#000}
347 .black-background{background:#000}
348 .blue{color:#0000bf}
349 .blue-background{background:#0000fa}
350 .fuchsia{color:#bf00bf}
351 .fuchsia-background{background:#fa00fa}
352 .gray{color:#606060}
353 .gray-background{background:#7d7d7d}
354 .green{color:#006000}
355 .green-background{background:#007d00}
356 .lime{color:#00bf00}
357 .lime-background{background:#00fa00}
358 .maroon{color:#600000}
359 .maroon-background{background:#7d0000}
360 .navy{color:#000060}
361 .navy-background{background:#00007d}
362 .olive{color:#606000}
363 .olive-background{background:#7d7d00}
364 .purple{color:#600060}
365 .purple-background{background:#7d007d}
366 .red{color:#bf0000}
367 .red-background{background:#fa0000}
368 .silver{color:#909090}
369 .silver-background{background:#bcbcbc}
370 .teal{color:#006060}
371 .teal-background{background:#007d7d}
372 .white{color:#bfbfbf}
373 .white-background{background:#fafafa}
374 .yellow{color:#bfbf00}
375 .yellow-background{background:#fafa00}
376 span.icon>.fa{cursor:default}
377 a span.icon>.fa{cursor:inherit}
378 .admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
379 .admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
380 .admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
381 .admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
382 .admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
383 .admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
384 .conum[data-value]{display:inline-block;color:#fff!important;background:rgba(0,0,0,.8);border-radius:50%;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
385 .conum[data-value] *{color:#fff!important}
386 .conum[data-value]+b{display:none}
387 .conum[data-value]::after{content:attr(data-value)}
388 pre .conum[data-value]{position:relative;top:-.125em}
389 b.conum *{color:inherit!important}
390 .conum:not([data-value]):empty{display:none}
391 dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
392 h1,h2,p,td.content,span.alt,summary{letter-spacing:-.01em}
393 p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
394 p,blockquote,dt,td.content,td.hdlist1,span.alt,summary{font-size:1.0625rem}
395 p{margin-bottom:1.25rem}
396 .sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
397 .exampleblock>.content{background:#fffef7;border-color:#e0e0dc;box-shadow:0 1px 4px #e0e0dc}
398 .print-only{display:none!important}
399 @page{margin:1.25cm .75cm}
400 @media print{*{box-shadow:none!important;text-shadow:none!important}
401 html{font-size:80%}
402 a{color:inherit!important;text-decoration:underline!important}
403 a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
404 a[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
405 abbr[title]{border-bottom:1px dotted}
406 abbr[title]::after{content:" (" attr(title) ")"}
407 pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
408 thead{display:table-header-group}
409 svg{max-width:100%}
410 p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
411 h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
412 #header,#content,#footnotes,#footer{max-width:none}
413 #toc,.sidebarblock,.exampleblock>.content{background:none!important}
414 #toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
415 body.book #header{text-align:center}
416 body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
417 body.book #header .details{border:0!important;display:block;padding:0!important}
418 body.book #header .details span:first-child{margin-left:0!important}
419 body.book #header .details br{display:block}
420 body.book #header .details br+span::before{content:none!important}
421 body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
422 body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
423 .listingblock code[data-lang]::before{display:block}
424 #footer{padding:0 .9375em}
425 .hide-on-print{display:none!important}
426 .print-only{display:block!important}
427 .hide-for-print{display:none!important}
428 .show-for-print{display:inherit!important}}
429 @media amzn-kf8,print{#header>h1:first-child{margin-top:1.25rem}
430 .sect1{padding:0!important}
431 .sect1+.sect1{border:0}
432 #footer{background:none}
433 #footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
434 @media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
435 </style>
436 <style>
437 pre>code {
438 display: inline;
440 </style>
441 </head>
442 <body class="article">
443 <div id="header">
444 <h1>Fighting regressions with git bisect</h1>
445 <div class="details">
446 <span id="author" class="author">Christian Couder</span><br/>
447 <span id="email" class="email"><a href="mailto:chriscool@tuxfamily.org">chriscool@tuxfamily.org</a></span><br/>
448 </div>
449 </div>
450 <div id="content">
451 <div class="sect1">
452 <h2 id="_abstract">Abstract</h2>
453 <div class="sectionbody">
454 <div class="paragraph">
455 <p>"git bisect" enables software users and developers to easily find the
456 commit that introduced a regression. We show why it is important to
457 have good tools to fight regressions. We describe how "git bisect"
458 works from the outside and the algorithms it uses inside. Then we
459 explain how to take advantage of "git bisect" to improve current
460 practices. And we discuss how "git bisect" could improve in the
461 future.</p>
462 </div>
463 </div>
464 </div>
465 <div class="sect1">
466 <h2 id="_introduction_to_git_bisect">Introduction to "git bisect"</h2>
467 <div class="sectionbody">
468 <div class="paragraph">
469 <p>Git is a Distributed Version Control system (DVCS) created by Linus
470 Torvalds and maintained by Junio Hamano.</p>
471 </div>
472 <div class="paragraph">
473 <p>In Git like in many other Version Control Systems (VCS), the different
474 states of the data that is managed by the system are called
475 commits. And, as VCS are mostly used to manage software source code,
476 sometimes "interesting" changes of behavior in the software are
477 introduced in some commits.</p>
478 </div>
479 <div class="paragraph">
480 <p>In fact people are specially interested in commits that introduce a
481 "bad" behavior, called a bug or a regression. They are interested in
482 these commits because a commit (hopefully) contains a very small set
483 of source code changes. And it&#8217;s much easier to understand and
484 properly fix a problem when you only need to check a very small set of
485 changes, than when you don&#8217;t know where look in the first place.</p>
486 </div>
487 <div class="paragraph">
488 <p>So to help people find commits that introduce a "bad" behavior, the
489 "git bisect" set of commands was invented. And it follows of course
490 that in "git bisect" parlance, commits where the "interesting
491 behavior" is present are called "bad" commits, while other commits are
492 called "good" commits. And a commit that introduce the behavior we are
493 interested in is called a "first bad commit". Note that there could be
494 more than one "first bad commit" in the commit space we are searching.</p>
495 </div>
496 <div class="paragraph">
497 <p>So "git bisect" is designed to help find a "first bad commit". And to
498 be as efficient as possible, it tries to perform a binary search.</p>
499 </div>
500 </div>
501 </div>
502 <div class="sect1">
503 <h2 id="_fighting_regressions_overview">Fighting regressions overview</h2>
504 <div class="sectionbody">
505 <div class="sect2">
506 <h3 id="_regressions_a_big_problem">Regressions: a big problem</h3>
507 <div class="paragraph">
508 <p>Regressions are a big problem in the software industry. But it&#8217;s
509 difficult to put some real numbers behind that claim.</p>
510 </div>
511 <div class="paragraph">
512 <p>There are some numbers about bugs in general, like a NIST study in
513 2002 <a href="#1">[1]</a> that said:</p>
514 </div>
515 <div class="quoteblock">
516 <blockquote>
517 <div class="paragraph">
518 <p>Software bugs, or errors, are so prevalent and so detrimental that
519 they cost the U.S. economy an estimated $59.5 billion annually, or
520 about 0.6 percent of the gross domestic product, according to a newly
521 released study commissioned by the Department of Commerce&#8217;s National
522 Institute of Standards and Technology (NIST). At the national level,
523 over half of the costs are borne by software users and the remainder
524 by software developers/vendors. The study also found that, although
525 all errors cannot be removed, more than a third of these costs, or an
526 estimated $22.2 billion, could be eliminated by an improved testing
527 infrastructure that enables earlier and more effective identification
528 and removal of software defects. These are the savings associated with
529 finding an increased percentage (but not 100 percent) of errors closer
530 to the development stages in which they are introduced. Currently,
531 over half of all errors are not found until "downstream" in the
532 development process or during post-sale software use.</p>
533 </div>
534 </blockquote>
535 </div>
536 <div class="paragraph">
537 <p>And then:</p>
538 </div>
539 <div class="quoteblock">
540 <blockquote>
541 <div class="paragraph">
542 <p>Software developers already spend approximately 80 percent of
543 development costs on identifying and correcting defects, and yet few
544 products of any type other than software are shipped with such high
545 levels of errors.</p>
546 </div>
547 </blockquote>
548 </div>
549 <div class="paragraph">
550 <p>Eventually the conclusion started with:</p>
551 </div>
552 <div class="quoteblock">
553 <blockquote>
554 <div class="paragraph">
555 <p>The path to higher software quality is significantly improved software
556 testing.</p>
557 </div>
558 </blockquote>
559 </div>
560 <div class="paragraph">
561 <p>There are other estimates saying that 80% of the cost related to
562 software is about maintenance <a href="#2">[2]</a>.</p>
563 </div>
564 <div class="paragraph">
565 <p>Though, according to Wikipedia <a href="#3">[3]</a>:</p>
566 </div>
567 <div class="quoteblock">
568 <blockquote>
569 <div class="paragraph">
570 <p>A common perception of maintenance is that it is merely fixing
571 bugs. However, studies and surveys over the years have indicated that
572 the majority, over 80%, of the maintenance effort is used for
573 non-corrective actions (Pigosky 1997). This perception is perpetuated
574 by users submitting problem reports that in reality are functionality
575 enhancements to the system.</p>
576 </div>
577 </blockquote>
578 </div>
579 <div class="paragraph">
580 <p>But we can guess that improving on existing software is very costly
581 because you have to watch out for regressions. At least this would
582 make the above studies consistent among themselves.</p>
583 </div>
584 <div class="paragraph">
585 <p>Of course some kind of software is developed, then used during some
586 time without being improved on much, and then finally thrown away. In
587 this case, of course, regressions may not be a big problem. But on the
588 other hand, there is a lot of big software that is continually
589 developed and maintained during years or even tens of years by a lot
590 of people. And as there are often many people who depend (sometimes
591 critically) on such software, regressions are a really big problem.</p>
592 </div>
593 <div class="paragraph">
594 <p>One such software is the Linux kernel. And if we look at the Linux
595 kernel, we can see that a lot of time and effort is spent to fight
596 regressions. The release cycle start with a 2 weeks long merge
597 window. Then the first release candidate (rc) version is tagged. And
598 after that about 7 or 8 more rc versions will appear with around one
599 week between each of them, before the final release.</p>
600 </div>
601 <div class="paragraph">
602 <p>The time between the first rc release and the final release is
603 supposed to be used to test rc versions and fight bugs and especially
604 regressions. And this time is more than 80% of the release cycle
605 time. But this is not the end of the fight yet, as of course it
606 continues after the release.</p>
607 </div>
608 <div class="paragraph">
609 <p>And then this is what Ingo Molnar (a well known Linux kernel
610 developer) says about his use of git bisect:</p>
611 </div>
612 <div class="quoteblock">
613 <blockquote>
614 <div class="paragraph">
615 <p>I most actively use it during the merge window (when a lot of trees
616 get merged upstream and when the influx of bugs is the highest) - and
617 yes, there have been cases that i used it multiple times a day. My
618 average is roughly once a day.</p>
619 </div>
620 </blockquote>
621 </div>
622 <div class="paragraph">
623 <p>So regressions are fought all the time by developers, and indeed it is
624 well known that bugs should be fixed as soon as possible, so as soon
625 as they are found. That&#8217;s why it is interesting to have good tools for
626 this purpose.</p>
627 </div>
628 </div>
629 <div class="sect2">
630 <h3 id="_other_tools_to_fight_regressions">Other tools to fight regressions</h3>
631 <div class="paragraph">
632 <p>So what are the tools used to fight regressions? They are nearly the
633 same as those used to fight regular bugs. The only specific tools are
634 test suites and tools similar as "git bisect".</p>
635 </div>
636 <div class="paragraph">
637 <p>Test suites are very nice. But when they are used alone, they are
638 supposed to be used so that all the tests are checked after each
639 commit. This means that they are not very efficient, because many
640 tests are run for no interesting result, and they suffer from
641 combinatorial explosion.</p>
642 </div>
643 <div class="paragraph">
644 <p>In fact the problem is that big software often has many different
645 configuration options and that each test case should pass for each
646 configuration after each commit. So if you have for each release: N
647 configurations, M commits and T test cases, you should perform:</p>
648 </div>
649 <div class="listingblock">
650 <div class="content">
651 <pre>N * M * T tests</pre>
652 </div>
653 </div>
654 <div class="paragraph">
655 <p>where N, M and T are all growing with the size your software.</p>
656 </div>
657 <div class="paragraph">
658 <p>So very soon it will not be possible to completely test everything.</p>
659 </div>
660 <div class="paragraph">
661 <p>And if some bugs slip through your test suite, then you can add a test
662 to your test suite. But if you want to use your new improved test
663 suite to find where the bug slipped in, then you will either have to
664 emulate a bisection process or you will perhaps bluntly test each
665 commit backward starting from the "bad" commit you have which may be
666 very wasteful.</p>
667 </div>
668 </div>
669 </div>
670 </div>
671 <div class="sect1">
672 <h2 id="_git_bisect_overview">"git bisect" overview</h2>
673 <div class="sectionbody">
674 <div class="sect2">
675 <h3 id="_starting_a_bisection">Starting a bisection</h3>
676 <div class="paragraph">
677 <p>The first "git bisect" subcommand to use is "git bisect start" to
678 start the search. Then bounds must be set to limit the commit
679 space. This is done usually by giving one "bad" and at least one
680 "good" commit. They can be passed in the initial call to "git bisect
681 start" like this:</p>
682 </div>
683 <div class="listingblock">
684 <div class="content">
685 <pre>$ git bisect start [BAD [GOOD...]]</pre>
686 </div>
687 </div>
688 <div class="paragraph">
689 <p>or they can be set using:</p>
690 </div>
691 <div class="listingblock">
692 <div class="content">
693 <pre>$ git bisect bad [COMMIT]</pre>
694 </div>
695 </div>
696 <div class="paragraph">
697 <p>and:</p>
698 </div>
699 <div class="listingblock">
700 <div class="content">
701 <pre>$ git bisect good [COMMIT...]</pre>
702 </div>
703 </div>
704 <div class="paragraph">
705 <p>where BAD, GOOD and COMMIT are all names that can be resolved to a
706 commit.</p>
707 </div>
708 <div class="paragraph">
709 <p>Then "git bisect" will checkout a commit of its choosing and ask the
710 user to test it, like this:</p>
711 </div>
712 <div class="listingblock">
713 <div class="content">
714 <pre>$ git bisect start v2.6.27 v2.6.25
715 Bisecting: 10928 revisions left to test after this (roughly 14 steps)
716 [2ec65f8b89ea003c27ff7723525a2ee335a2b393] x86: clean up using max_low_pfn on 32-bit</pre>
717 </div>
718 </div>
719 <div class="paragraph">
720 <p>Note that the example that we will use is really a toy example, we
721 will be looking for the first commit that has a version like
722 "2.6.26-something", that is the commit that has a "SUBLEVEL = 26" line
723 in the top level Makefile. This is a toy example because there are
724 better ways to find this commit with Git than using "git bisect" (for
725 example "git blame" or "git log -S&lt;string&gt;").</p>
726 </div>
727 </div>
728 <div class="sect2">
729 <h3 id="_driving_a_bisection_manually">Driving a bisection manually</h3>
730 <div class="paragraph">
731 <p>At this point there are basically 2 ways to drive the search. It can
732 be driven manually by the user or it can be driven automatically by a
733 script or a command.</p>
734 </div>
735 <div class="paragraph">
736 <p>If the user is driving it, then at each step of the search, the user
737 will have to test the current commit and say if it is "good" or "bad"
738 using the "git bisect good" or "git bisect bad" commands respectively
739 that have been described above. For example:</p>
740 </div>
741 <div class="listingblock">
742 <div class="content">
743 <pre>$ git bisect bad
744 Bisecting: 5480 revisions left to test after this (roughly 13 steps)
745 [66c0b394f08fd89236515c1c84485ea712a157be] KVM: kill file-&gt;f_count abuse in kvm</pre>
746 </div>
747 </div>
748 <div class="paragraph">
749 <p>And after a few more steps like that, "git bisect" will eventually
750 find a first bad commit:</p>
751 </div>
752 <div class="listingblock">
753 <div class="content">
754 <pre>$ git bisect bad
755 2ddcca36c8bcfa251724fe342c8327451988be0d is the first bad commit
756 commit 2ddcca36c8bcfa251724fe342c8327451988be0d
757 Author: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
758 Date: Sat May 3 11:59:44 2008 -0700
760 Linux 2.6.26-rc1
762 :100644 100644 5cf82581... 4492984e... M Makefile</pre>
763 </div>
764 </div>
765 <div class="paragraph">
766 <p>At this point we can see what the commit does, check it out (if it&#8217;s
767 not already checked out) or tinker with it, for example:</p>
768 </div>
769 <div class="listingblock">
770 <div class="content">
771 <pre>$ git show HEAD
772 commit 2ddcca36c8bcfa251724fe342c8327451988be0d
773 Author: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
774 Date: Sat May 3 11:59:44 2008 -0700
776 Linux 2.6.26-rc1
778 diff --git a/Makefile b/Makefile
779 index 5cf8258..4492984 100644
780 --- a/Makefile
781 +++ b/Makefile
782 @@ -1,7 +1,7 @@
783 VERSION = 2
784 PATCHLEVEL = 6
785 -SUBLEVEL = 25
786 -EXTRAVERSION =
787 +SUBLEVEL = 26
788 +EXTRAVERSION = -rc1
789 NAME = Funky Weasel is Jiggy wit it
791 # *DOCUMENTATION*</pre>
792 </div>
793 </div>
794 <div class="paragraph">
795 <p>And when we are finished we can use "git bisect reset" to go back to
796 the branch we were in before we started bisecting:</p>
797 </div>
798 <div class="listingblock">
799 <div class="content">
800 <pre>$ git bisect reset
801 Checking out files: 100% (21549/21549), done.
802 Previous HEAD position was 2ddcca3... Linux 2.6.26-rc1
803 Switched to branch 'master'</pre>
804 </div>
805 </div>
806 </div>
807 <div class="sect2">
808 <h3 id="_driving_a_bisection_automatically">Driving a bisection automatically</h3>
809 <div class="paragraph">
810 <p>The other way to drive the bisection process is to tell "git bisect"
811 to launch a script or command at each bisection step to know if the
812 current commit is "good" or "bad". To do that, we use the "git bisect
813 run" command. For example:</p>
814 </div>
815 <div class="listingblock">
816 <div class="content">
817 <pre>$ git bisect start v2.6.27 v2.6.25
818 Bisecting: 10928 revisions left to test after this (roughly 14 steps)
819 [2ec65f8b89ea003c27ff7723525a2ee335a2b393] x86: clean up using max_low_pfn on 32-bit
821 $ git bisect run grep '^SUBLEVEL = 25' Makefile
822 running grep ^SUBLEVEL = 25 Makefile
823 Bisecting: 5480 revisions left to test after this (roughly 13 steps)
824 [66c0b394f08fd89236515c1c84485ea712a157be] KVM: kill file-&gt;f_count abuse in kvm
825 running grep ^SUBLEVEL = 25 Makefile
826 SUBLEVEL = 25
827 Bisecting: 2740 revisions left to test after this (roughly 12 steps)
828 [671294719628f1671faefd4882764886f8ad08cb] V4L/DVB(7879): Adding cx18 Support for mxl5005s
831 running grep ^SUBLEVEL = 25 Makefile
832 Bisecting: 0 revisions left to test after this (roughly 0 steps)
833 [2ddcca36c8bcfa251724fe342c8327451988be0d] Linux 2.6.26-rc1
834 running grep ^SUBLEVEL = 25 Makefile
835 2ddcca36c8bcfa251724fe342c8327451988be0d is the first bad commit
836 commit 2ddcca36c8bcfa251724fe342c8327451988be0d
837 Author: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
838 Date: Sat May 3 11:59:44 2008 -0700
840 Linux 2.6.26-rc1
842 :100644 100644 5cf82581... 4492984e... M Makefile
843 bisect run success</pre>
844 </div>
845 </div>
846 <div class="paragraph">
847 <p>In this example, we passed "grep <em>^SUBLEVEL = 25</em> Makefile" as
848 parameter to "git bisect run". This means that at each step, the grep
849 command we passed will be launched. And if it exits with code 0 (that
850 means success) then git bisect will mark the current state as
851 "good". If it exits with code 1 (or any code between 1 and 127
852 included, except the special code 125), then the current state will be
853 marked as "bad".</p>
854 </div>
855 <div class="paragraph">
856 <p>Exit code between 128 and 255 are special to "git bisect run". They
857 make it stop immediately the bisection process. This is useful for
858 example if the command passed takes too long to complete, because you
859 can kill it with a signal and it will stop the bisection process.</p>
860 </div>
861 <div class="paragraph">
862 <p>It can also be useful in scripts passed to "git bisect run" to "exit
863 255" if some very abnormal situation is detected.</p>
864 </div>
865 </div>
866 <div class="sect2">
867 <h3 id="_avoiding_untestable_commits">Avoiding untestable commits</h3>
868 <div class="paragraph">
869 <p>Sometimes it happens that the current state cannot be tested, for
870 example if it does not compile because there was a bug preventing it
871 at that time. This is what the special exit code 125 is for. It tells
872 "git bisect run" that the current commit should be marked as
873 untestable and that another one should be chosen and checked out.</p>
874 </div>
875 <div class="paragraph">
876 <p>If the bisection process is driven manually, you can use "git bisect
877 skip" to do the same thing. (In fact the special exit code 125 makes
878 "git bisect run" use "git bisect skip" in the background.)</p>
879 </div>
880 <div class="paragraph">
881 <p>Or if you want more control, you can inspect the current state using
882 for example "git bisect visualize". It will launch gitk (or "git log"
883 if the <code>DISPLAY</code> environment variable is not set) to help you find a
884 better bisection point.</p>
885 </div>
886 <div class="paragraph">
887 <p>Either way, if you have a string of untestable commits, it might
888 happen that the regression you are looking for has been introduced by
889 one of these untestable commits. In this case it&#8217;s not possible to
890 tell for sure which commit introduced the regression.</p>
891 </div>
892 <div class="paragraph">
893 <p>So if you used "git bisect skip" (or the run script exited with
894 special code 125) you could get a result like this:</p>
895 </div>
896 <div class="listingblock">
897 <div class="content">
898 <pre>There are only 'skip'ped commits left to test.
899 The first bad commit could be any of:
900 15722f2fa328eaba97022898a305ffc8172db6b1
901 78e86cf3e850bd755bb71831f42e200626fbd1e0
902 e15b73ad3db9b48d7d1ade32f8cd23a751fe0ace
903 070eab2303024706f2924822bfec8b9847e4ac1b
904 We cannot bisect more!</pre>
905 </div>
906 </div>
907 </div>
908 <div class="sect2">
909 <h3 id="_saving_a_log_and_replaying_it">Saving a log and replaying it</h3>
910 <div class="paragraph">
911 <p>If you want to show other people your bisection process, you can get a
912 log using for example:</p>
913 </div>
914 <div class="listingblock">
915 <div class="content">
916 <pre>$ git bisect log &gt; bisect_log.txt</pre>
917 </div>
918 </div>
919 <div class="paragraph">
920 <p>And it is possible to replay it using:</p>
921 </div>
922 <div class="listingblock">
923 <div class="content">
924 <pre>$ git bisect replay bisect_log.txt</pre>
925 </div>
926 </div>
927 </div>
928 </div>
929 </div>
930 <div class="sect1">
931 <h2 id="_git_bisect_details">"git bisect" details</h2>
932 <div class="sectionbody">
933 <div class="sect2">
934 <h3 id="_bisection_algorithm">Bisection algorithm</h3>
935 <div class="paragraph">
936 <p>As the Git commits form a directed acyclic graph (DAG), finding the
937 best bisection commit to test at each step is not so simple. Anyway
938 Linus found and implemented a "truly stupid" algorithm, later improved
939 by Junio Hamano, that works quite well.</p>
940 </div>
941 <div class="paragraph">
942 <p>So the algorithm used by "git bisect" to find the best bisection
943 commit when there are no skipped commits is the following:</p>
944 </div>
945 <div class="paragraph">
946 <p>1) keep only the commits that:</p>
947 </div>
948 <div class="paragraph">
949 <p>a) are ancestor of the "bad" commit (including the "bad" commit itself),
950 b) are not ancestor of a "good" commit (excluding the "good" commits).</p>
951 </div>
952 <div class="paragraph">
953 <p>This means that we get rid of the uninteresting commits in the DAG.</p>
954 </div>
955 <div class="paragraph">
956 <p>For example if we start with a graph like this:</p>
957 </div>
958 <div class="listingblock">
959 <div class="content">
960 <pre>G-Y-G-W-W-W-X-X-X-X
962 W-W-B
964 Y---G-W---W
965 \ / \
966 Y-Y X-X-X-X
968 -&gt; time goes this way -&gt;</pre>
969 </div>
970 </div>
971 <div class="paragraph">
972 <p>where B is the "bad" commit, "G" are "good" commits and W, X, and Y
973 are other commits, we will get the following graph after this first
974 step:</p>
975 </div>
976 <div class="listingblock">
977 <div class="content">
978 <pre>W-W-W
980 W-W-B
982 W---W</pre>
983 </div>
984 </div>
985 <div class="paragraph">
986 <p>So only the W and B commits will be kept. Because commits X and Y will
987 have been removed by rules a) and b) respectively, and because commits
988 G are removed by rule b) too.</p>
989 </div>
990 <div class="paragraph">
991 <p>Note for Git users, that it is equivalent as keeping only the commit
992 given by:</p>
993 </div>
994 <div class="listingblock">
995 <div class="content">
996 <pre>git rev-list BAD --not GOOD1 GOOD2...</pre>
997 </div>
998 </div>
999 <div class="paragraph">
1000 <p>Also note that we don&#8217;t require the commits that are kept to be
1001 descendants of a "good" commit. So in the following example, commits W
1002 and Z will be kept:</p>
1003 </div>
1004 <div class="listingblock">
1005 <div class="content">
1006 <pre>G-W-W-W-B
1008 Z-Z</pre>
1009 </div>
1010 </div>
1011 <div class="paragraph">
1012 <p>2) starting from the "good" ends of the graph, associate to each
1013 commit the number of ancestors it has plus one</p>
1014 </div>
1015 <div class="paragraph">
1016 <p>For example with the following graph where H is the "bad" commit and A
1017 and D are some parents of some "good" commits:</p>
1018 </div>
1019 <div class="listingblock">
1020 <div class="content">
1021 <pre>A-B-C
1023 F-G-H
1025 D---E</pre>
1026 </div>
1027 </div>
1028 <div class="paragraph">
1029 <p>this will give:</p>
1030 </div>
1031 <div class="listingblock">
1032 <div class="content">
1033 <pre>1 2 3
1034 A-B-C
1035 \6 7 8
1036 F-G-H
1037 1 2/
1038 D---E</pre>
1039 </div>
1040 </div>
1041 <div class="paragraph">
1042 <p>3) associate to each commit: min(X, N - X)</p>
1043 </div>
1044 <div class="paragraph">
1045 <p>where X is the value associated to the commit in step 2) and N is the
1046 total number of commits in the graph.</p>
1047 </div>
1048 <div class="paragraph">
1049 <p>In the above example we have N = 8, so this will give:</p>
1050 </div>
1051 <div class="listingblock">
1052 <div class="content">
1053 <pre>1 2 3
1054 A-B-C
1055 \2 1 0
1056 F-G-H
1057 1 2/
1058 D---E</pre>
1059 </div>
1060 </div>
1061 <div class="paragraph">
1062 <p>4) the best bisection point is the commit with the highest associated
1063 number</p>
1064 </div>
1065 <div class="paragraph">
1066 <p>So in the above example the best bisection point is commit C.</p>
1067 </div>
1068 <div class="paragraph">
1069 <p>5) note that some shortcuts are implemented to speed up the algorithm</p>
1070 </div>
1071 <div class="paragraph">
1072 <p>As we know N from the beginning, we know that min(X, N - X) can&#8217;t be
1073 greater than N/2. So during steps 2) and 3), if we would associate N/2
1074 to a commit, then we know this is the best bisection point. So in this
1075 case we can just stop processing any other commit and return the
1076 current commit.</p>
1077 </div>
1078 </div>
1079 <div class="sect2">
1080 <h3 id="_bisection_algorithm_debugging">Bisection algorithm debugging</h3>
1081 <div class="paragraph">
1082 <p>For any commit graph, you can see the number associated with each
1083 commit using "git rev-list --bisect-all".</p>
1084 </div>
1085 <div class="paragraph">
1086 <p>For example, for the above graph, a command like:</p>
1087 </div>
1088 <div class="listingblock">
1089 <div class="content">
1090 <pre>$ git rev-list --bisect-all BAD --not GOOD1 GOOD2</pre>
1091 </div>
1092 </div>
1093 <div class="paragraph">
1094 <p>would output something like:</p>
1095 </div>
1096 <div class="listingblock">
1097 <div class="content">
1098 <pre>e15b73ad3db9b48d7d1ade32f8cd23a751fe0ace (dist=3)
1099 15722f2fa328eaba97022898a305ffc8172db6b1 (dist=2)
1100 78e86cf3e850bd755bb71831f42e200626fbd1e0 (dist=2)
1101 a1939d9a142de972094af4dde9a544e577ddef0e (dist=2)
1102 070eab2303024706f2924822bfec8b9847e4ac1b (dist=1)
1103 a3864d4f32a3bf5ed177ddef598490a08760b70d (dist=1)
1104 a41baa717dd74f1180abf55e9341bc7a0bb9d556 (dist=1)
1105 9e622a6dad403b71c40979743bb9d5be17b16bd6 (dist=0)</pre>
1106 </div>
1107 </div>
1108 </div>
1109 <div class="sect2">
1110 <h3 id="_bisection_algorithm_discussed">Bisection algorithm discussed</h3>
1111 <div class="paragraph">
1112 <p>First let&#8217;s define "best bisection point". We will say that a commit X
1113 is a best bisection point or a best bisection commit if knowing its
1114 state ("good" or "bad") gives as much information as possible whether
1115 the state of the commit happens to be "good" or "bad".</p>
1116 </div>
1117 <div class="paragraph">
1118 <p>This means that the best bisection commits are the commits where the
1119 following function is maximum:</p>
1120 </div>
1121 <div class="listingblock">
1122 <div class="content">
1123 <pre>f(X) = min(information_if_good(X), information_if_bad(X))</pre>
1124 </div>
1125 </div>
1126 <div class="paragraph">
1127 <p>where information_if_good(X) is the information we get if X is good
1128 and information_if_bad(X) is the information we get if X is bad.</p>
1129 </div>
1130 <div class="paragraph">
1131 <p>Now we will suppose that there is only one "first bad commit". This
1132 means that all its descendants are "bad" and all the other commits are
1133 "good". And we will suppose that all commits have an equal probability
1134 of being good or bad, or of being the first bad commit, so knowing the
1135 state of c commits gives always the same amount of information
1136 wherever these c commits are on the graph and whatever c is. (So we
1137 suppose that these commits being for example on a branch or near a
1138 good or a bad commit does not give more or less information).</p>
1139 </div>
1140 <div class="paragraph">
1141 <p>Let&#8217;s also suppose that we have a cleaned up graph like one after step
1142 1) in the bisection algorithm above. This means that we can measure
1143 the information we get in terms of number of commit we can remove
1144 from the graph..</p>
1145 </div>
1146 <div class="paragraph">
1147 <p>And let&#8217;s take a commit X in the graph.</p>
1148 </div>
1149 <div class="paragraph">
1150 <p>If X is found to be "good", then we know that its ancestors are all
1151 "good", so we want to say that:</p>
1152 </div>
1153 <div class="listingblock">
1154 <div class="content">
1155 <pre>information_if_good(X) = number_of_ancestors(X) (TRUE)</pre>
1156 </div>
1157 </div>
1158 <div class="paragraph">
1159 <p>And this is true because at step 1) b) we remove the ancestors of the
1160 "good" commits.</p>
1161 </div>
1162 <div class="paragraph">
1163 <p>If X is found to be "bad", then we know that its descendants are all
1164 "bad", so we want to say that:</p>
1165 </div>
1166 <div class="listingblock">
1167 <div class="content">
1168 <pre>information_if_bad(X) = number_of_descendants(X) (WRONG)</pre>
1169 </div>
1170 </div>
1171 <div class="paragraph">
1172 <p>But this is wrong because at step 1) a) we keep only the ancestors of
1173 the bad commit. So we get more information when a commit is marked as
1174 "bad", because we also know that the ancestors of the previous "bad"
1175 commit that are not ancestors of the new "bad" commit are not the
1176 first bad commit. We don&#8217;t know if they are good or bad, but we know
1177 that they are not the first bad commit because they are not ancestor
1178 of the new "bad" commit.</p>
1179 </div>
1180 <div class="paragraph">
1181 <p>So when a commit is marked as "bad" we know we can remove all the
1182 commits in the graph except those that are ancestors of the new "bad"
1183 commit. This means that:</p>
1184 </div>
1185 <div class="listingblock">
1186 <div class="content">
1187 <pre>information_if_bad(X) = N - number_of_ancestors(X) (TRUE)</pre>
1188 </div>
1189 </div>
1190 <div class="paragraph">
1191 <p>where N is the number of commits in the (cleaned up) graph.</p>
1192 </div>
1193 <div class="paragraph">
1194 <p>So in the end this means that to find the best bisection commits we
1195 should maximize the function:</p>
1196 </div>
1197 <div class="listingblock">
1198 <div class="content">
1199 <pre>f(X) = min(number_of_ancestors(X), N - number_of_ancestors(X))</pre>
1200 </div>
1201 </div>
1202 <div class="paragraph">
1203 <p>And this is nice because at step 2) we compute number_of_ancestors(X)
1204 and so at step 3) we compute f(X).</p>
1205 </div>
1206 <div class="paragraph">
1207 <p>Let&#8217;s take the following graph as an example:</p>
1208 </div>
1209 <div class="listingblock">
1210 <div class="content">
1211 <pre> G-H-I-J
1213 A-B-C-D-E-F O
1215 K-L-M-N</pre>
1216 </div>
1217 </div>
1218 <div class="paragraph">
1219 <p>If we compute the following non optimal function on it:</p>
1220 </div>
1221 <div class="listingblock">
1222 <div class="content">
1223 <pre>g(X) = min(number_of_ancestors(X), number_of_descendants(X))</pre>
1224 </div>
1225 </div>
1226 <div class="paragraph">
1227 <p>we get:</p>
1228 </div>
1229 <div class="listingblock">
1230 <div class="content">
1231 <pre> 4 3 2 1
1232 G-H-I-J
1233 1 2 3 4 5 6/ \0
1234 A-B-C-D-E-F O
1236 K-L-M-N
1237 4 3 2 1</pre>
1238 </div>
1239 </div>
1240 <div class="paragraph">
1241 <p>but with the algorithm used by git bisect we get:</p>
1242 </div>
1243 <div class="listingblock">
1244 <div class="content">
1245 <pre> 7 7 6 5
1246 G-H-I-J
1247 1 2 3 4 5 6/ \0
1248 A-B-C-D-E-F O
1250 K-L-M-N
1251 7 7 6 5</pre>
1252 </div>
1253 </div>
1254 <div class="paragraph">
1255 <p>So we chose G, H, K or L as the best bisection point, which is better
1256 than F. Because if for example L is bad, then we will know not only
1257 that L, M and N are bad but also that G, H, I and J are not the first
1258 bad commit (since we suppose that there is only one first bad commit
1259 and it must be an ancestor of L).</p>
1260 </div>
1261 <div class="paragraph">
1262 <p>So the current algorithm seems to be the best possible given what we
1263 initially supposed.</p>
1264 </div>
1265 </div>
1266 <div class="sect2">
1267 <h3 id="_skip_algorithm">Skip algorithm</h3>
1268 <div class="paragraph">
1269 <p>When some commits have been skipped (using "git bisect skip"), then
1270 the bisection algorithm is the same for step 1) to 3). But then we use
1271 roughly the following steps:</p>
1272 </div>
1273 <div class="paragraph">
1274 <p>6) sort the commit by decreasing associated value</p>
1275 </div>
1276 <div class="paragraph">
1277 <p>7) if the first commit has not been skipped, we can return it and stop
1278 here</p>
1279 </div>
1280 <div class="paragraph">
1281 <p>8) otherwise filter out all the skipped commits in the sorted list</p>
1282 </div>
1283 <div class="paragraph">
1284 <p>9) use a pseudo random number generator (PRNG) to generate a random
1285 number between 0 and 1</p>
1286 </div>
1287 <div class="paragraph">
1288 <p>10) multiply this random number with its square root to bias it toward
1289 0</p>
1290 </div>
1291 <div class="paragraph">
1292 <p>11) multiply the result by the number of commits in the filtered list
1293 to get an index into this list</p>
1294 </div>
1295 <div class="paragraph">
1296 <p>12) return the commit at the computed index</p>
1297 </div>
1298 </div>
1299 <div class="sect2">
1300 <h3 id="_skip_algorithm_discussed">Skip algorithm discussed</h3>
1301 <div class="paragraph">
1302 <p>After step 7) (in the skip algorithm), we could check if the second
1303 commit has been skipped and return it if it is not the case. And in
1304 fact that was the algorithm we used from when "git bisect skip" was
1305 developed in Git version 1.5.4 (released on February 1st 2008) until
1306 Git version 1.6.4 (released July 29th 2009).</p>
1307 </div>
1308 <div class="paragraph">
1309 <p>But Ingo Molnar and H. Peter Anvin (another well known linux kernel
1310 developer) both complained that sometimes the best bisection points
1311 all happened to be in an area where all the commits are
1312 untestable. And in this case the user was asked to test many
1313 untestable commits, which could be very inefficient.</p>
1314 </div>
1315 <div class="paragraph">
1316 <p>Indeed untestable commits are often untestable because a breakage was
1317 introduced at one time, and that breakage was fixed only after many
1318 other commits were introduced.</p>
1319 </div>
1320 <div class="paragraph">
1321 <p>This breakage is of course most of the time unrelated to the breakage
1322 we are trying to locate in the commit graph. But it prevents us to
1323 know if the interesting "bad behavior" is present or not.</p>
1324 </div>
1325 <div class="paragraph">
1326 <p>So it is a fact that commits near an untestable commit have a high
1327 probability of being untestable themselves. And the best bisection
1328 commits are often found together too (due to the bisection algorithm).</p>
1329 </div>
1330 <div class="paragraph">
1331 <p>This is why it is a bad idea to just chose the next best unskipped
1332 bisection commit when the first one has been skipped.</p>
1333 </div>
1334 <div class="paragraph">
1335 <p>We found that most commits on the graph may give quite a lot of
1336 information when they are tested. And the commits that will not on
1337 average give a lot of information are the one near the good and bad
1338 commits.</p>
1339 </div>
1340 <div class="paragraph">
1341 <p>So using a PRNG with a bias to favor commits away from the good and
1342 bad commits looked like a good choice.</p>
1343 </div>
1344 <div class="paragraph">
1345 <p>One obvious improvement to this algorithm would be to look for a
1346 commit that has an associated value near the one of the best bisection
1347 commit, and that is on another branch, before using the PRNG. Because
1348 if such a commit exists, then it is not very likely to be untestable
1349 too, so it will probably give more information than a nearly randomly
1350 chosen one.</p>
1351 </div>
1352 </div>
1353 <div class="sect2">
1354 <h3 id="_checking_merge_bases">Checking merge bases</h3>
1355 <div class="paragraph">
1356 <p>There is another tweak in the bisection algorithm that has not been
1357 described in the "bisection algorithm" above.</p>
1358 </div>
1359 <div class="paragraph">
1360 <p>We supposed in the previous examples that the "good" commits were
1361 ancestors of the "bad" commit. But this is not a requirement of "git
1362 bisect".</p>
1363 </div>
1364 <div class="paragraph">
1365 <p>Of course the "bad" commit cannot be an ancestor of a "good" commit,
1366 because the ancestors of the good commits are supposed to be
1367 "good". And all the "good" commits must be related to the bad commit.
1368 They cannot be on a branch that has no link with the branch of the
1369 "bad" commit. But it is possible for a good commit to be related to a
1370 bad commit and yet not be neither one of its ancestor nor one of its
1371 descendants.</p>
1372 </div>
1373 <div class="paragraph">
1374 <p>For example, there can be a "main" branch, and a "dev" branch that was
1375 forked of the main branch at a commit named "D" like this:</p>
1376 </div>
1377 <div class="listingblock">
1378 <div class="content">
1379 <pre>A-B-C-D-E-F-G &lt;--main
1381 H-I-J &lt;--dev</pre>
1382 </div>
1383 </div>
1384 <div class="paragraph">
1385 <p>The commit "D" is called a "merge base" for branch "main" and "dev"
1386 because it&#8217;s the best common ancestor for these branches for a merge.</p>
1387 </div>
1388 <div class="paragraph">
1389 <p>Now let&#8217;s suppose that commit J is bad and commit G is good and that
1390 we apply the bisection algorithm like it has been previously
1391 described.</p>
1392 </div>
1393 <div class="paragraph">
1394 <p>As described in step 1) b) of the bisection algorithm, we remove all
1395 the ancestors of the good commits because they are supposed to be good
1396 too.</p>
1397 </div>
1398 <div class="paragraph">
1399 <p>So we would be left with only:</p>
1400 </div>
1401 <div class="listingblock">
1402 <div class="content">
1403 <pre>H-I-J</pre>
1404 </div>
1405 </div>
1406 <div class="paragraph">
1407 <p>But what happens if the first bad commit is "B" and if it has been
1408 fixed in the "main" branch by commit "F"?</p>
1409 </div>
1410 <div class="paragraph">
1411 <p>The result of such a bisection would be that we would find that H is
1412 the first bad commit, when in fact it&#8217;s B. So that would be wrong!</p>
1413 </div>
1414 <div class="paragraph">
1415 <p>And yes it can happen in practice that people working on one branch
1416 are not aware that people working on another branch fixed a bug! It
1417 could also happen that F fixed more than one bug or that it is a
1418 revert of some big development effort that was not ready to be
1419 released.</p>
1420 </div>
1421 <div class="paragraph">
1422 <p>In fact development teams often maintain both a development branch and
1423 a maintenance branch, and it would be quite easy for them if "git
1424 bisect" just worked when they want to bisect a regression on the
1425 development branch that is not on the maintenance branch. They should
1426 be able to start bisecting using:</p>
1427 </div>
1428 <div class="listingblock">
1429 <div class="content">
1430 <pre>$ git bisect start dev main</pre>
1431 </div>
1432 </div>
1433 <div class="paragraph">
1434 <p>To enable that additional nice feature, when a bisection is started
1435 and when some good commits are not ancestors of the bad commit, we
1436 first compute the merge bases between the bad and the good commits and
1437 we chose these merge bases as the first commits that will be checked
1438 out and tested.</p>
1439 </div>
1440 <div class="paragraph">
1441 <p>If it happens that one merge base is bad, then the bisection process
1442 is stopped with a message like:</p>
1443 </div>
1444 <div class="listingblock">
1445 <div class="content">
1446 <pre>The merge base BBBBBB is bad.
1447 This means the bug has been fixed between BBBBBB and [GGGGGG,...].</pre>
1448 </div>
1449 </div>
1450 <div class="paragraph">
1451 <p>where BBBBBB is the sha1 hash of the bad merge base and [GGGGGG,&#8230;&#8203;]
1452 is a comma separated list of the sha1 of the good commits.</p>
1453 </div>
1454 <div class="paragraph">
1455 <p>If some of the merge bases are skipped, then the bisection process
1456 continues, but the following message is printed for each skipped merge
1457 base:</p>
1458 </div>
1459 <div class="listingblock">
1460 <div class="content">
1461 <pre>Warning: the merge base between BBBBBB and [GGGGGG,...] must be skipped.
1462 So we cannot be sure the first bad commit is between MMMMMM and BBBBBB.
1463 We continue anyway.</pre>
1464 </div>
1465 </div>
1466 <div class="paragraph">
1467 <p>where BBBBBB is the sha1 hash of the bad commit, MMMMMM is the sha1
1468 hash of the merge base that is skipped and [GGGGGG,&#8230;&#8203;] is a comma
1469 separated list of the sha1 of the good commits.</p>
1470 </div>
1471 <div class="paragraph">
1472 <p>So if there is no bad merge base, the bisection process continues as
1473 usual after this step.</p>
1474 </div>
1475 </div>
1476 </div>
1477 </div>
1478 <div class="sect1">
1479 <h2 id="_best_bisecting_practices">Best bisecting practices</h2>
1480 <div class="sectionbody">
1481 <div class="sect2">
1482 <h3 id="_using_test_suites_and_git_bisect_together">Using test suites and git bisect together</h3>
1483 <div class="paragraph">
1484 <p>If you both have a test suite and use git bisect, then it becomes less
1485 important to check that all tests pass after each commit. Though of
1486 course it is probably a good idea to have some checks to avoid
1487 breaking too many things because it could make bisecting other bugs
1488 more difficult.</p>
1489 </div>
1490 <div class="paragraph">
1491 <p>You can focus your efforts to check at a few points (for example rc
1492 and beta releases) that all the T test cases pass for all the N
1493 configurations. And when some tests don&#8217;t pass you can use "git
1494 bisect" (or better "git bisect run"). So you should perform roughly:</p>
1495 </div>
1496 <div class="listingblock">
1497 <div class="content">
1498 <pre>c * N * T + b * M * log2(M) tests</pre>
1499 </div>
1500 </div>
1501 <div class="paragraph">
1502 <p>where c is the number of rounds of test (so a small constant) and b is
1503 the ratio of bug per commit (hopefully a small constant too).</p>
1504 </div>
1505 <div class="paragraph">
1506 <p>So of course it&#8217;s much better as it&#8217;s O(N * T) vs O(N * T * M) if
1507 you would test everything after each commit.</p>
1508 </div>
1509 <div class="paragraph">
1510 <p>This means that test suites are good to prevent some bugs from being
1511 committed and they are also quite good to tell you that you have some
1512 bugs. But they are not so good to tell you where some bugs have been
1513 introduced. To tell you that efficiently, git bisect is needed.</p>
1514 </div>
1515 <div class="paragraph">
1516 <p>The other nice thing with test suites, is that when you have one, you
1517 already know how to test for bad behavior. So you can use this
1518 knowledge to create a new test case for "git bisect" when it appears
1519 that there is a regression. So it will be easier to bisect the bug and
1520 fix it. And then you can add the test case you just created to your
1521 test suite.</p>
1522 </div>
1523 <div class="paragraph">
1524 <p>So if you know how to create test cases and how to bisect, you will be
1525 subject to a virtuous circle:</p>
1526 </div>
1527 <div class="paragraph">
1528 <p>more tests &#8658; easier to create tests &#8658; easier to bisect &#8658; more tests</p>
1529 </div>
1530 <div class="paragraph">
1531 <p>So test suites and "git bisect" are complementary tools that are very
1532 powerful and efficient when used together.</p>
1533 </div>
1534 </div>
1535 <div class="sect2">
1536 <h3 id="_bisecting_build_failures">Bisecting build failures</h3>
1537 <div class="paragraph">
1538 <p>You can very easily automatically bisect broken builds using something
1539 like:</p>
1540 </div>
1541 <div class="listingblock">
1542 <div class="content">
1543 <pre>$ git bisect start BAD GOOD
1544 $ git bisect run make</pre>
1545 </div>
1546 </div>
1547 </div>
1548 <div class="sect2">
1549 <h3 id="_passing_sh_c_some_commands_to_git_bisect_run">Passing sh -c "some commands" to "git bisect run"</h3>
1550 <div class="paragraph">
1551 <p>For example:</p>
1552 </div>
1553 <div class="listingblock">
1554 <div class="content">
1555 <pre>$ git bisect run sh -c "make || exit 125; ./my_app | grep 'good output'"</pre>
1556 </div>
1557 </div>
1558 <div class="paragraph">
1559 <p>On the other hand if you do this often, then it can be worth having
1560 scripts to avoid too much typing.</p>
1561 </div>
1562 </div>
1563 <div class="sect2">
1564 <h3 id="_finding_performance_regressions">Finding performance regressions</h3>
1565 <div class="paragraph">
1566 <p>Here is an example script that comes slightly modified from a real
1567 world script used by Junio Hamano <a href="#4">[4]</a>.</p>
1568 </div>
1569 <div class="paragraph">
1570 <p>This script can be passed to "git bisect run" to find the commit that
1571 introduced a performance regression:</p>
1572 </div>
1573 <div class="listingblock">
1574 <div class="content">
1575 <pre>#!/bin/sh
1577 # Build errors are not what I am interested in.
1578 make my_app || exit 255
1580 # We are checking if it stops in a reasonable amount of time, so
1581 # let it run in the background...
1583 ./my_app &gt;log 2&gt;&amp;1 &amp;
1585 # ... and grab its process ID.
1586 pid=$!
1588 # ... and then wait for sufficiently long.
1589 sleep $NORMAL_TIME
1591 # ... and then see if the process is still there.
1592 if kill -0 $pid
1593 then
1594 # It is still running -- that is bad.
1595 kill $pid; sleep 1; kill $pid;
1596 exit 1
1597 else
1598 # It has already finished (the $pid process was no more),
1599 # and we are happy.
1600 exit 0
1601 fi</pre>
1602 </div>
1603 </div>
1604 </div>
1605 <div class="sect2">
1606 <h3 id="_following_general_best_practices">Following general best practices</h3>
1607 <div class="paragraph">
1608 <p>It is obviously a good idea not to have commits with changes that
1609 knowingly break things, even if some other commits later fix the
1610 breakage.</p>
1611 </div>
1612 <div class="paragraph">
1613 <p>It is also a good idea when using any VCS to have only one small
1614 logical change in each commit.</p>
1615 </div>
1616 <div class="paragraph">
1617 <p>The smaller the changes in your commit, the most effective "git
1618 bisect" will be. And you will probably need "git bisect" less in the
1619 first place, as small changes are easier to review even if they are
1620 only reviewed by the committer.</p>
1621 </div>
1622 <div class="paragraph">
1623 <p>Another good idea is to have good commit messages. They can be very
1624 helpful to understand why some changes were made.</p>
1625 </div>
1626 <div class="paragraph">
1627 <p>These general best practices are very helpful if you bisect often.</p>
1628 </div>
1629 </div>
1630 <div class="sect2">
1631 <h3 id="_avoiding_bug_prone_merges">Avoiding bug prone merges</h3>
1632 <div class="paragraph">
1633 <p>First merges by themselves can introduce some regressions even when
1634 the merge needs no source code conflict resolution. This is because a
1635 semantic change can happen in one branch while the other branch is not
1636 aware of it.</p>
1637 </div>
1638 <div class="paragraph">
1639 <p>For example one branch can change the semantic of a function while the
1640 other branch add more calls to the same function.</p>
1641 </div>
1642 <div class="paragraph">
1643 <p>This is made much worse if many files have to be fixed to resolve
1644 conflicts. That&#8217;s why such merges are called "evil merges". They can
1645 make regressions very difficult to track down. It can even be
1646 misleading to know the first bad commit if it happens to be such a
1647 merge, because people might think that the bug comes from bad conflict
1648 resolution when it comes from a semantic change in one branch.</p>
1649 </div>
1650 <div class="paragraph">
1651 <p>Anyway "git rebase" can be used to linearize history. This can be used
1652 either to avoid merging in the first place. Or it can be used to
1653 bisect on a linear history instead of the non linear one, as this
1654 should give more information in case of a semantic change in one
1655 branch.</p>
1656 </div>
1657 <div class="paragraph">
1658 <p>Merges can be also made simpler by using smaller branches or by using
1659 many topic branches instead of only long version related branches.</p>
1660 </div>
1661 <div class="paragraph">
1662 <p>And testing can be done more often in special integration branches
1663 like linux-next for the linux kernel.</p>
1664 </div>
1665 </div>
1666 <div class="sect2">
1667 <h3 id="_adapting_your_work_flow">Adapting your work-flow</h3>
1668 <div class="paragraph">
1669 <p>A special work-flow to process regressions can give great results.</p>
1670 </div>
1671 <div class="paragraph">
1672 <p>Here is an example of a work-flow used by Andreas Ericsson:</p>
1673 </div>
1674 <div class="ulist">
1675 <ul>
1676 <li>
1677 <p>write, in the test suite, a test script that exposes the regression</p>
1678 </li>
1679 <li>
1680 <p>use "git bisect run" to find the commit that introduced it</p>
1681 </li>
1682 <li>
1683 <p>fix the bug that is often made obvious by the previous step</p>
1684 </li>
1685 <li>
1686 <p>commit both the fix and the test script (and if needed more tests)</p>
1687 </li>
1688 </ul>
1689 </div>
1690 <div class="paragraph">
1691 <p>And here is what Andreas said about this work-flow <a href="#5">[5]</a>:</p>
1692 </div>
1693 <div class="quoteblock">
1694 <blockquote>
1695 <div class="paragraph">
1696 <p>To give some hard figures, we used to have an average report-to-fix
1697 cycle of 142.6 hours (according to our somewhat weird bug-tracker
1698 which just measures wall-clock time). Since we moved to Git, we&#8217;ve
1699 lowered that to 16.2 hours. Primarily because we can stay on top of
1700 the bug fixing now, and because everyone&#8217;s jockeying to get to fix
1701 bugs (we&#8217;re quite proud of how lazy we are to let Git find the bugs
1702 for us). Each new release results in ~40% fewer bugs (almost certainly
1703 due to how we now feel about writing tests).</p>
1704 </div>
1705 </blockquote>
1706 </div>
1707 <div class="paragraph">
1708 <p>Clearly this work-flow uses the virtuous circle between test suites
1709 and "git bisect". In fact it makes it the standard procedure to deal
1710 with regression.</p>
1711 </div>
1712 <div class="paragraph">
1713 <p>In other messages Andreas says that they also use the "best practices"
1714 described above: small logical commits, topic branches, no evil
1715 merge,&#8230;&#8203; These practices all improve the bisectability of the commit
1716 graph, by making it easier and more useful to bisect.</p>
1717 </div>
1718 <div class="paragraph">
1719 <p>So a good work-flow should be designed around the above points. That
1720 is making bisecting easier, more useful and standard.</p>
1721 </div>
1722 </div>
1723 <div class="sect2">
1724 <h3 id="_involving_qa_people_and_if_possible_end_users">Involving QA people and if possible end users</h3>
1725 <div class="paragraph">
1726 <p>One nice about "git bisect" is that it is not only a developer
1727 tool. It can effectively be used by QA people or even end users (if
1728 they have access to the source code or if they can get access to all
1729 the builds).</p>
1730 </div>
1731 <div class="paragraph">
1732 <p>There was a discussion at one point on the linux kernel mailing list
1733 of whether it was ok to always ask end user to bisect, and very good
1734 points were made to support the point of view that it is ok.</p>
1735 </div>
1736 <div class="paragraph">
1737 <p>For example David Miller wrote <a href="#6">[6]</a>:</p>
1738 </div>
1739 <div class="quoteblock">
1740 <blockquote>
1741 <div class="paragraph">
1742 <p>What people don&#8217;t get is that this is a situation where the "end node
1743 principle" applies. When you have limited resources (here: developers)
1744 you don&#8217;t push the bulk of the burden upon them. Instead you push
1745 things out to the resource you have a lot of, the end nodes (here:
1746 users), so that the situation actually scales.</p>
1747 </div>
1748 </blockquote>
1749 </div>
1750 <div class="paragraph">
1751 <p>This means that it is often "cheaper" if QA people or end users can do
1752 it.</p>
1753 </div>
1754 <div class="paragraph">
1755 <p>What is interesting too is that end users that are reporting bugs (or
1756 QA people that reproduced a bug) have access to the environment where
1757 the bug happens. So they can often more easily reproduce a
1758 regression. And if they can bisect, then more information will be
1759 extracted from the environment where the bug happens, which means that
1760 it will be easier to understand and then fix the bug.</p>
1761 </div>
1762 <div class="paragraph">
1763 <p>For open source projects it can be a good way to get more useful
1764 contributions from end users, and to introduce them to QA and
1765 development activities.</p>
1766 </div>
1767 </div>
1768 <div class="sect2">
1769 <h3 id="_using_complex_scripts">Using complex scripts</h3>
1770 <div class="paragraph">
1771 <p>In some cases like for kernel development it can be worth developing
1772 complex scripts to be able to fully automate bisecting.</p>
1773 </div>
1774 <div class="paragraph">
1775 <p>Here is what Ingo Molnar says about that <a href="#7">[7]</a>:</p>
1776 </div>
1777 <div class="quoteblock">
1778 <blockquote>
1779 <div class="paragraph">
1780 <p>i have a fully automated bootup-hang bisection script. It is based on
1781 "git-bisect run". I run the script, it builds and boots kernels fully
1782 automatically, and when the bootup fails (the script notices that via
1783 the serial log, which it continuously watches - or via a timeout, if
1784 the system does not come up within 10 minutes it&#8217;s a "bad" kernel),
1785 the script raises my attention via a beep and i power cycle the test
1786 box. (yeah, i should make use of a managed power outlet to 100%
1787 automate it)</p>
1788 </div>
1789 </blockquote>
1790 </div>
1791 </div>
1792 <div class="sect2">
1793 <h3 id="_combining_test_suites_git_bisect_and_other_systems_together">Combining test suites, git bisect and other systems together</h3>
1794 <div class="paragraph">
1795 <p>We have seen that test suites and git bisect are very powerful when
1796 used together. It can be even more powerful if you can combine them
1797 with other systems.</p>
1798 </div>
1799 <div class="paragraph">
1800 <p>For example some test suites could be run automatically at night with
1801 some unusual (or even random) configurations. And if a regression is
1802 found by a test suite, then "git bisect" can be automatically
1803 launched, and its result can be emailed to the author of the first bad
1804 commit found by "git bisect", and perhaps other people too. And a new
1805 entry in the bug tracking system could be automatically created too.</p>
1806 </div>
1807 </div>
1808 </div>
1809 </div>
1810 <div class="sect1">
1811 <h2 id="_the_future_of_bisecting">The future of bisecting</h2>
1812 <div class="sectionbody">
1813 <div class="sect2">
1814 <h3 id="_git_replace">"git replace"</h3>
1815 <div class="paragraph">
1816 <p>We saw earlier that "git bisect skip" is now using a PRNG to try to
1817 avoid areas in the commit graph where commits are untestable. The
1818 problem is that sometimes the first bad commit will be in an
1819 untestable area.</p>
1820 </div>
1821 <div class="paragraph">
1822 <p>To simplify the discussion we will suppose that the untestable area is
1823 a simple string of commits and that it was created by a breakage
1824 introduced by one commit (let&#8217;s call it BBC for bisect breaking
1825 commit) and later fixed by another one (let&#8217;s call it BFC for bisect
1826 fixing commit).</p>
1827 </div>
1828 <div class="paragraph">
1829 <p>For example:</p>
1830 </div>
1831 <div class="listingblock">
1832 <div class="content">
1833 <pre>...-Y-BBC-X1-X2-X3-X4-X5-X6-BFC-Z-...</pre>
1834 </div>
1835 </div>
1836 <div class="paragraph">
1837 <p>where we know that Y is good and BFC is bad, and where BBC and X1 to
1838 X6 are untestable.</p>
1839 </div>
1840 <div class="paragraph">
1841 <p>In this case if you are bisecting manually, what you can do is create
1842 a special branch that starts just before the BBC. The first commit in
1843 this branch should be the BBC with the BFC squashed into it. And the
1844 other commits in the branch should be the commits between BBC and BFC
1845 rebased on the first commit of the branch and then the commit after
1846 BFC also rebased on.</p>
1847 </div>
1848 <div class="paragraph">
1849 <p>For example:</p>
1850 </div>
1851 <div class="listingblock">
1852 <div class="content">
1853 <pre> (BBC+BFC)-X1'-X2'-X3'-X4'-X5'-X6'-Z'
1855 ...-Y-BBC-X1-X2-X3-X4-X5-X6-BFC-Z-...</pre>
1856 </div>
1857 </div>
1858 <div class="paragraph">
1859 <p>where commits quoted with ' have been rebased.</p>
1860 </div>
1861 <div class="paragraph">
1862 <p>You can easily create such a branch with Git using interactive rebase.</p>
1863 </div>
1864 <div class="paragraph">
1865 <p>For example using:</p>
1866 </div>
1867 <div class="listingblock">
1868 <div class="content">
1869 <pre>$ git rebase -i Y Z</pre>
1870 </div>
1871 </div>
1872 <div class="paragraph">
1873 <p>and then moving BFC after BBC and squashing it.</p>
1874 </div>
1875 <div class="paragraph">
1876 <p>After that you can start bisecting as usual in the new branch and you
1877 should eventually find the first bad commit.</p>
1878 </div>
1879 <div class="paragraph">
1880 <p>For example:</p>
1881 </div>
1882 <div class="listingblock">
1883 <div class="content">
1884 <pre>$ git bisect start Z' Y</pre>
1885 </div>
1886 </div>
1887 <div class="paragraph">
1888 <p>If you are using "git bisect run", you can use the same manual fix up
1889 as above, and then start another "git bisect run" in the special
1890 branch. Or as the "git bisect" man page says, the script passed to
1891 "git bisect run" can apply a patch before it compiles and test the
1892 software <a href="#8">[8]</a>. The patch should turn a current untestable commits
1893 into a testable one. So the testing will result in "good" or "bad" and
1894 "git bisect" will be able to find the first bad commit. And the script
1895 should not forget to remove the patch once the testing is done before
1896 exiting from the script.</p>
1897 </div>
1898 <div class="paragraph">
1899 <p>(Note that instead of a patch you can use "git cherry-pick BFC" to
1900 apply the fix, and in this case you should use "git reset --hard
1901 HEAD^" to revert the cherry-pick after testing and before returning
1902 from the script.)</p>
1903 </div>
1904 <div class="paragraph">
1905 <p>But the above ways to work around untestable areas are a little bit
1906 clunky. Using special branches is nice because these branches can be
1907 shared by developers like usual branches, but the risk is that people
1908 will get many such branches. And it disrupts the normal "git bisect"
1909 work-flow. So, if you want to use "git bisect run" completely
1910 automatically, you have to add special code in your script to restart
1911 bisection in the special branches.</p>
1912 </div>
1913 <div class="paragraph">
1914 <p>Anyway one can notice in the above special branch example that the Z'
1915 and Z commits should point to the same source code state (the same
1916 "tree" in git parlance). That&#8217;s because Z' result from applying the
1917 same changes as Z just in a slightly different order.</p>
1918 </div>
1919 <div class="paragraph">
1920 <p>So if we could just "replace" Z by Z' when we bisect, then we would
1921 not need to add anything to a script. It would just work for anyone in
1922 the project sharing the special branches and the replacements.</p>
1923 </div>
1924 <div class="paragraph">
1925 <p>With the example above that would give:</p>
1926 </div>
1927 <div class="listingblock">
1928 <div class="content">
1929 <pre> (BBC+BFC)-X1'-X2'-X3'-X4'-X5'-X6'-Z'-...
1931 ...-Y-BBC-X1-X2-X3-X4-X5-X6-BFC-Z</pre>
1932 </div>
1933 </div>
1934 <div class="paragraph">
1935 <p>That&#8217;s why the "git replace" command was created. Technically it
1936 stores replacements "refs" in the "refs/replace/" hierarchy. These
1937 "refs" are like branches (that are stored in "refs/heads/") or tags
1938 (that are stored in "refs/tags"), and that means that they can
1939 automatically be shared like branches or tags among developers.</p>
1940 </div>
1941 <div class="paragraph">
1942 <p>"git replace" is a very powerful mechanism. It can be used to fix
1943 commits in already released history, for example to change the commit
1944 message or the author. And it can also be used instead of git "grafts"
1945 to link a repository with another old repository.</p>
1946 </div>
1947 <div class="paragraph">
1948 <p>In fact it&#8217;s this last feature that "sold" it to the Git community, so
1949 it is now in the "master" branch of Git&#8217;s Git repository and it should
1950 be released in Git 1.6.5 in October or November 2009.</p>
1951 </div>
1952 <div class="paragraph">
1953 <p>One problem with "git replace" is that currently it stores all the
1954 replacements refs in "refs/replace/", but it would be perhaps better
1955 if the replacement refs that are useful only for bisecting would be in
1956 "refs/replace/bisect/". This way the replacement refs could be used
1957 only for bisecting, while other refs directly in "refs/replace/" would
1958 be used nearly all the time.</p>
1959 </div>
1960 </div>
1961 <div class="sect2">
1962 <h3 id="_bisecting_sporadic_bugs">Bisecting sporadic bugs</h3>
1963 <div class="paragraph">
1964 <p>Another possible improvement to "git bisect" would be to optionally
1965 add some redundancy to the tests performed so that it would be more
1966 reliable when tracking sporadic bugs.</p>
1967 </div>
1968 <div class="paragraph">
1969 <p>This has been requested by some kernel developers because some bugs
1970 called sporadic bugs do not appear in all the kernel builds because
1971 they are very dependent on the compiler output.</p>
1972 </div>
1973 <div class="paragraph">
1974 <p>The idea is that every 3 test for example, "git bisect" could ask the
1975 user to test a commit that has already been found to be "good" or
1976 "bad" (because one of its descendants or one of its ancestors has been
1977 found to be "good" or "bad" respectively). If it happens that a commit
1978 has been previously incorrectly classified then the bisection can be
1979 aborted early, hopefully before too many mistakes have been made. Then
1980 the user will have to look at what happened and then restart the
1981 bisection using a fixed bisect log.</p>
1982 </div>
1983 <div class="paragraph">
1984 <p>There is already a project called BBChop created by Ealdwulf Wuffinga
1985 on Github that does something like that using Bayesian Search Theory
1986 <a href="#9">[9]</a>:</p>
1987 </div>
1988 <div class="quoteblock">
1989 <blockquote>
1990 <div class="paragraph">
1991 <p>BBChop is like <em>git bisect</em> (or equivalent), but works when your bug
1992 is intermittent. That is, it works in the presence of false negatives
1993 (when a version happens to work this time even though it contains the
1994 bug). It assumes that there are no false positives (in principle, the
1995 same approach would work, but adding it may be non-trivial).</p>
1996 </div>
1997 </blockquote>
1998 </div>
1999 <div class="paragraph">
2000 <p>But BBChop is independent of any VCS and it would be easier for Git
2001 users to have something integrated in Git.</p>
2002 </div>
2003 </div>
2004 </div>
2005 </div>
2006 <div class="sect1">
2007 <h2 id="_conclusion">Conclusion</h2>
2008 <div class="sectionbody">
2009 <div class="paragraph">
2010 <p>We have seen that regressions are an important problem, and that "git
2011 bisect" has nice features that complement very well practices and
2012 other tools, especially test suites, that are generally used to fight
2013 regressions. But it might be needed to change some work-flows and
2014 (bad) habits to get the most out of it.</p>
2015 </div>
2016 <div class="paragraph">
2017 <p>Some improvements to the algorithms inside "git bisect" are possible
2018 and some new features could help in some cases, but overall "git
2019 bisect" works already very well, is used a lot, and is already very
2020 useful. To back up that last claim, let&#8217;s give the final word to Ingo
2021 Molnar when he was asked by the author how much time does he think
2022 "git bisect" saves him when he uses it:</p>
2023 </div>
2024 <div class="quoteblock">
2025 <blockquote>
2026 <div class="paragraph">
2027 <p>a <em>lot</em>.</p>
2028 </div>
2029 <div class="paragraph">
2030 <p>About ten years ago did i do my first <em>bisection</em> of a Linux patch
2031 queue. That was prior the Git (and even prior the BitKeeper) days. I
2032 literally days spent sorting out patches, creating what in essence
2033 were standalone commits that i guessed to be related to that bug.</p>
2034 </div>
2035 <div class="paragraph">
2036 <p>It was a tool of absolute last resort. I&#8217;d rather spend days looking
2037 at printk output than do a manual <em>patch bisection</em>.</p>
2038 </div>
2039 <div class="paragraph">
2040 <p>With Git bisect it&#8217;s a breeze: in the best case i can get a ~15 step
2041 kernel bisection done in 20-30 minutes, in an automated way. Even with
2042 manual help or when bisecting multiple, overlapping bugs, it&#8217;s rarely
2043 more than an hour.</p>
2044 </div>
2045 <div class="paragraph">
2046 <p>In fact it&#8217;s invaluable because there are bugs i would never even
2047 <em>try</em> to debug if it wasn&#8217;t for git bisect. In the past there were bug
2048 patterns that were immediately hopeless for me to debug - at best i
2049 could send the crash/bug signature to lkml and hope that someone else
2050 can think of something.</p>
2051 </div>
2052 <div class="paragraph">
2053 <p>And even if a bisection fails today it tells us something valuable
2054 about the bug: that it&#8217;s non-deterministic - timing or kernel image
2055 layout dependent.</p>
2056 </div>
2057 <div class="paragraph">
2058 <p>So git bisect is unconditional goodness - and feel free to quote that
2059 ;-)</p>
2060 </div>
2061 </blockquote>
2062 </div>
2063 </div>
2064 </div>
2065 <div class="sect1">
2066 <h2 id="_acknowledgments">Acknowledgments</h2>
2067 <div class="sectionbody">
2068 <div class="paragraph">
2069 <p>Many thanks to Junio Hamano for his help in reviewing this paper, for
2070 reviewing the patches I sent to the Git mailing list, for discussing
2071 some ideas and helping me improve them, for improving "git bisect" a
2072 lot and for his awesome work in maintaining and developing Git.</p>
2073 </div>
2074 <div class="paragraph">
2075 <p>Many thanks to Ingo Molnar for giving me very useful information that
2076 appears in this paper, for commenting on this paper, for his
2077 suggestions to improve "git bisect" and for evangelizing "git bisect"
2078 on the linux kernel mailing lists.</p>
2079 </div>
2080 <div class="paragraph">
2081 <p>Many thanks to Linus Torvalds for inventing, developing and
2082 evangelizing "git bisect", Git and Linux.</p>
2083 </div>
2084 <div class="paragraph">
2085 <p>Many thanks to the many other great people who helped one way or
2086 another when I worked on Git, especially to Andreas Ericsson, Johannes
2087 Schindelin, H. Peter Anvin, Daniel Barkalow, Bill Lear, John Hawley,
2088 Shawn O. Pierce, Jeff King, Sam Vilain, Jon Seymour.</p>
2089 </div>
2090 <div class="paragraph">
2091 <p>Many thanks to the Linux-Kongress program committee for choosing the
2092 author to given a talk and for publishing this paper.</p>
2093 </div>
2094 </div>
2095 </div>
2096 <div class="sect1">
2097 <h2 id="_references">References</h2>
2098 <div class="sectionbody">
2099 <div class="ulist">
2100 <ul>
2101 <li>
2102 <p>[[[1]]] <a href="https://web.archive.org/web/20091206032101/http://www.nist.gov/public_affairs/releases/n02-10.htm"><em>Software Errors Cost U.S. Economy $59.5 Billion Annually</em>. Nist News Release.</a> See also <a href="https://www.nist.gov/system/files/documents/director/planning/report02-3.pdf"><em>The Economic Impacts of Inadequate Infratructure for Software Testing</em>. Nist Planning Report 02-3</a>, Executive Summary and Chapter 8.</p>
2103 </li>
2104 <li>
2105 <p>[[[2]]] <a href="https://www.oracle.com/java/technologies/javase/codeconventions-introduction.html"><em>Code Conventions for the Java Programming Language: 1. Introduction</em>. Sun Microsystems.</a></p>
2106 </li>
2107 <li>
2108 <p>[[[3]]] <a href="https://en.wikipedia.org/wiki/Software_maintenance"><em>Software maintenance</em>. Wikipedia.</a></p>
2109 </li>
2110 <li>
2111 <p>[[[4]]] <a href="https://lore.kernel.org/git/7vps5xsbwp.fsf_-_@assigned-by-dhcp.cox.net/">Junio C Hamano. <em>Automated bisect success story</em>.</a></p>
2112 </li>
2113 <li>
2114 <p>[[[5]]] <a href="https://lwn.net/Articles/317154/">Christian Couder. <em>Fully automated bisecting with "git bisect run"</em>. LWN.net.</a></p>
2115 </li>
2116 <li>
2117 <p>[[[6]]] <a href="https://lwn.net/Articles/277872/">Jonathan Corbet. <em>Bisection divides users and developers</em>. LWN.net.</a></p>
2118 </li>
2119 <li>
2120 <p>[[[7]]] <a href="https://lore.kernel.org/lkml/20071207113734.GA14598@elte.hu/">Ingo Molnar. <em>Re: BUG 2.6.23-rc3 can&#8217;t see sd partitions on Alpha</em>. Linux-kernel mailing list.</a></p>
2121 </li>
2122 <li>
2123 <p>[[[8]]] <a href="https://www.kernel.org/pub/software/scm/git/docs/git-bisect.html">Junio C Hamano and the git-list. <em>git-bisect(1) Manual Page</em>. Linux Kernel Archives.</a></p>
2124 </li>
2125 <li>
2126 <p>[[[9]]] <a href="https://github.com/Ealdwulf/bbchop">Ealdwulf. <em>bbchop</em>. GitHub.</a></p>
2127 </li>
2128 </ul>
2129 </div>
2130 </div>
2131 </div>
2132 </div>
2133 <div id="footer">
2134 <div id="footer-text">
2135 Last updated 2023-01-21 17:52:14 -0800
2136 </div>
2137 </div>
2138 </body>
2139 </html>