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