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