Investigating Regressions Quickly using Git Bisect

Investigating Regressions Quickly using Git Bisect

Bisect is a tool built into Git which allows you to step back through the history of your code in order to identify a particular change that introduced a bug. It does so in an efficient manner, meaning you don’t need to check every change, and it can save you hours of debugging.

In this talk John introduces you to Git Bisect and shows you real-world use cases. He covers using it to identify the cause of regressions, how it can save you time, and how to hook it up to automated testing.

This talk is suitable for anyone who is comfortable using Git for version control.

23e12888dcd87d07434b7621bc164958?s=128

John Blackbourn

December 07, 2018
Tweet

Transcript

  1. Investigating Regressions Quickly using Git Bisect John Blackbourn · @johnbillion

  2. Investigating Regressions Efficiently using Git Bisect John Blackbourn · @johnbillion

  3. “Well, it used to work...”

  4. dae2820 Version 3.1. 8cec81d Tighten up some Composer dependencies so

    things don't break so freely. 4ddb969 Use QM's wrapper function for path normalising to ensure compatibility. 13e4ff6 Built CSS. 1344cba Debug Bar extension taming. 4e4a7c5 More tweaks for the sorting controls. c87b614 Introduce a git attributes file so files can be excluded during packaging. a172b79 Update the tests. 7f94fd2 Update the readme file. bee172b Template Part file string normalization b53995b Link to the privacy statement instead of bundling it. 9353086 Switch to system default fonts. 82edf66 Fix the sorting arrows again. a88af25 Add a min-width to logger messages. a49a2ed Improvements to link icons, and add an icon to regular links. eace3c9 More specificity! cd8ef84 More tweaks to paddings, alignment, sizing, yadda yadda. 6658f6c Tweak the array element names in the Environment collector. 721d5be Automatically wrap all box containers for now. Needs a better solution at some point. 75616b8 Add some styles specific to mobile/touch devices. 0d1d9db More tweaks to column min widths and wrapping. 156b6f7 Show a warning message in the Overview panel when a PHP error is trigger during an Ajax request. 664875c Don't output toggle links or a blank HTTP API transport if not necessary. 6113d4a Add a human readable representation of transient timeouts, and prevent some wrapping. ecc697e Display human-readable environment values inline. 308cbec Display a warning when time or memory usage is above 75% of the respective limit. f054c1f Utilise the output wrappers when outputting logs. 88375ab Re-add style for the logger warning in the menu. a71197d Place HTML comments between each panel output. e4b9c19 Separate asset dependencies and dependents with commas. 1c9a183 Add missing i18n for various data in the Environment and Debug Bar panels. 3109f04 Add a tear down for the capability checks collector. 41fc043 Move more rules under the #query-monitor selector.
  5. 20d9981 Switch to using labels and buttons for table sorting

    controls. 214b435 Don't use a heading for the jQuery error message. 081664f Headings! fd100fd Update some more heading levels, introduce a heading for the panel menu. e686d4c Place focus on the panel when selecting one. 19b8deb Add a missing Sass variable. e1e665f Include buttons when adding the hover style to parent rows of focused links. ca196e2 Begin restructuring the panel heading levels. da1c060 Tweak the toolbar buttons further. 786d7fd When tabbing between links in tables, apply the row hover style to the parent row. 95be19c Fix the Sass file header. 0e4d33d Make use of selector nesting. fc30f71 Improve the panel menu item focus styles for keyboard navigation. de6d311 Amazing! It's possible to prevent the "overscroll" behaviour. cf76b56 Refactor the admin toolbar styles, add some more variables. 607f9bd Increase the file watch interval to give my CPU a break. 1b90cac More visual tweaks to the toolbar buttons. 2491ca9 Add a link hover color. 55a7a54 Add missing default statements. 67d117c Namespace the Sass variables and convert them to default values. 9624c2d Link to each asset source. 46d4b4f Re-calculate table striping after column sorting. 01bd4a2 Strip HTML from PHP error messages during collection instead of during output. eb8c996 Add a notice style and use it in the Capability Checks panel when it hasn't been enabled. f3ac8f0 Add a background colour when hovering over the filter controls. 1785b9a Add a background colour when hovering over the toolbar buttons. 9fe76c5 Prevent accidental text selection when resizing the panel. 1302938 Everything is important. f7d8b70 Increase some contrast. 12642d4 Version 3.0.1. b7e5999 Update the Sass and built CSS. ce7c345 I continually underestimate how messed up some websites are with regard to jQuery. bc793ad Don't remove the stored container height when closing the QM panel. See #326.
  6. Bisect “To cut or divide into two equal parts”

  7. None
  8. $ git bisect start $ git bisect good "2.6.10" $

    git bisect bad HEAD Bisecting: 74 revisions left to test after this (roughly 6 steps). [c20280a] Further tweaks to QM's output if JavaScript isn't available for any reason.
  9. None
  10. $ git bisect start $ git bisect good "2.6.10" $

    git bisect bad HEAD Bisecting: 74 revisions left to test after this (roughly 6 steps). [c20280a] Further tweaks to QM's output if JavaScript isn't available for any reason. $ git bisect bad Bisecting: 36 revisions left to test after this (roughly 5 steps). [a59860e] Correct some output priorities.
  11. None
  12. $ git bisect good Bisecting: 18 revisions left to test

    after this (roughly 4 steps). [c5f91e4] Consistent and correct output for closures and anonymous functions.
  13. None
  14. commit 6b3c8c2 Author: John Blackbourn Date: Mon Mar 16 00:27:08

    2015 +0000 Don't add a warning indicator to the admin bar menu if the `all` hook is in use. The warning in the Hooks output is sufficient. $ git bisect good 6b3c8c2 is the first bad commit
  15. $ git diff 1bd84ab 6b3c8c2 - public function admin_menu( array

    $menu ) { - $data = $this->collector->get_data(); - $args = array( - 'title' => $this->collector->name(), - ); - $menu[] = $this->menu( $args ); - return $menu; - } $ git bisect reset Previous HEAD position was 6b3c8c2... Don't add a warning indicator to the admin bar menu if the `all` hook is in use. Switched to branch 'master'
  16. We can do better!

  17. $ git bisect run test.php $ git bisect run behat

    features/menu.feature $ git bisect run test-menu.sh
  18. None
  19. $ git bisect run php -f test-menu.php running php -f

    test-menu.php Bisecting: 74 revisions left to test after this (roughly 6 steps) running php -f test-menu.php Bisecting: 36 revisions left to test after this (roughly 5 steps) running php -f test-menu.php Bisecting: 18 revisions left to test after this (roughly 4 steps) running php -f test-menu.php ... Bisecting: 0 revisions left to test after this (roughly 0 steps) running php -f test-menu.php 6b3c8c2 is the first bad commit
  20. We can do better!

  21. $ git bisect start -- path/to/code

  22. I hope you don’t need this advice very often John

    Blackbourn · @johnbillion